Upgraded to Angular 14
This commit is contained in:
2022-07-06 09:04:10 +05:30
parent f637f01954
commit 792ccf923f
46 changed files with 233 additions and 179 deletions

View File

@ -1,5 +1,10 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators,
} from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, of as observableOf } from 'rxjs';
@ -18,12 +23,12 @@ import { GuestBookService } from '../guest-book.service';
})
export class GuestBookDetailComponent implements OnInit, AfterViewInit {
@ViewChild('phone', { static: true }) phoneElement?: ElementRef;
form: FormGroup;
form: UntypedFormGroup;
item: GuestBook = new GuestBook();
customers: Observable<Customer[]>;
constructor(
private fb: FormBuilder,
private fb: UntypedFormBuilder,
private route: ActivatedRoute,
private router: Router,
private toaster: ToasterService,
@ -38,7 +43,7 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
address: null,
});
// Setup Account Autocomplete
this.customers = (this.form.get('phone') as FormControl).valueChanges.pipe(
this.customers = (this.form.get('phone') as UntypedFormControl).valueChanges.pipe(
startWith(null),
map((x) => (x !== null && x.length >= 1 ? x : null)),
debounceTime(150),

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import * as moment from 'moment';
@ -22,14 +22,14 @@ import { GuestBookListDataSource } from './guest-book-list-datasource';
export class GuestBookListComponent implements OnInit {
data: BehaviorSubject<GuestBook[]> = new BehaviorSubject<GuestBook[]>([]);
dataSource: GuestBookListDataSource = new GuestBookListDataSource(this.data);
form: FormGroup;
form: UntypedFormGroup;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['sno', 'name', 'phone', 'pax', 'date', 'action'];
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder,
private fb: UntypedFormBuilder,
private dialog: MatDialog,
private toaster: ToasterService,
private ser: GuestBookService,
@ -42,7 +42,7 @@ export class GuestBookListComponent implements OnInit {
}
listenToDateChange(): void {
(this.form.get('date') as FormControl).valueChanges
(this.form.get('date') as UntypedFormControl).valueChanges
.pipe(map((x) => moment(x).format('DD-MMM-YYYY')))
.subscribe((x) =>
this.ser.list(x).subscribe((list: GuestBookList) => {