Chore: Moved from Untyped to Stongly Typed forms.

This commit is contained in:
2022-07-15 13:24:25 +05:30
parent facf2df91e
commit 28f9bf2180
78 changed files with 1091 additions and 1004 deletions

View File

@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { FormControl, FormGroup } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { ActivatedRoute, Router } from '@angular/router';
@ -19,19 +19,19 @@ export class PurchasesComponent implements OnInit {
@ViewChild(MatSort, { static: true }) sort?: MatSort;
info: Purchases = new Purchases();
dataSource: PurchasesDataSource = new PurchasesDataSource(this.info.body);
form: UntypedFormGroup;
form: FormGroup<{
startDate: FormControl<Date>;
finishDate: FormControl<Date>;
}>;
selectedRowId = '';
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['product', 'quantity', 'rate', 'amount'];
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: UntypedFormBuilder,
) {
this.form = this.fb.group({
startDate: '',
finishDate: '',
constructor(private route: ActivatedRoute, private router: Router) {
this.form = new FormGroup({
startDate: new FormControl(new Date(), { nonNullable: true }),
finishDate: new FormControl(new Date(), { nonNullable: true }),
});
}