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
@@ -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 { ProductGroup } from '../../core/product-group';
@@ -13,18 +13,20 @@ import { ProductGroupService } from '../product-group.service';
})
export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: UntypedFormGroup;
form: FormGroup<{
name: FormControl<string | null>;
}>;
item: ProductGroup = new ProductGroup();
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: UntypedFormBuilder,
private toaster: ToasterService,
private ser: ProductGroupService,
) {
this.form = this.fb.group({
name: '',
this.form = new FormGroup({
name: new FormControl<string | null>(null),
});
}
@@ -65,7 +67,7 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
getItem(): ProductGroup {
const formModel = this.form.value;
this.item.name = formModel.name;
this.item.name = formModel.name!;
return this.item;
}
}
@@ -1,4 +1,4 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';