Chore: Moved from Untyped to Stongly Typed forms.

This commit is contained in:
tanshu committed 2022-07-15 13:24:25 +05:30
1 parent facf2df91e
commit 28f9bf2180
78 files changed
+1091 -1004

No files matched your search

@@ -1,5 +1,5 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { FormControl, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { CostCentre } from '../../core/cost-centre';
@@ -13,18 +13,20 @@ import { CostCentreService } from '../cost-centre.service';
})
export class CostCentreDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: UntypedFormGroup;
form: FormGroup<{
name: FormControl<string | null>;
}>;
item: CostCentre = new CostCentre();
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: UntypedFormBuilder,
private toaster: ToasterService,
private ser: CostCentreService,
) {
this.form = this.fb.group({
name: '',
this.form = new FormGroup({
name: new FormControl<string | null>(null),
});
}
@@ -65,7 +67,7 @@ export class CostCentreDetailComponent implements OnInit, AfterViewInit {
getItem(): CostCentre {
const formModel = this.form.value;
this.item.name = formModel.name;
this.item.name = formModel.name!;
return this.item;
}
}