Moving to strict.

Create form has now moved to constructor and route data subscribe is type safe.
This commit is contained in:
2020-11-23 09:18:02 +05:30
parent 30b1a3ef7d
commit 39e3cc51bb
52 changed files with 348 additions and 448 deletions

View File

@ -28,10 +28,6 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
private toaster: ToasterService,
private ser: ProductService,
) {
this.createForm();
}
createForm() {
this.form = this.fb.group({
code: { value: '', disabled: true },
name: '',
@ -49,7 +45,9 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
this.route.data.subscribe((data: { item: Product; productGroups: ProductGroup[] }) => {
this.route.data.subscribe((value) => {
const data = value as { item: Product; productGroups: ProductGroup[] };
this.productGroups = data.productGroups;
this.showItem(data.item);
});

View File

@ -32,7 +32,9 @@ export class ProductListComponent implements OnInit, AfterViewInit {
constructor(private route: ActivatedRoute, private fb: FormBuilder, private toCsv: ToCsvService) {
this.showExtended = false;
this.createForm();
this.form = this.fb.group({
filter: '',
});
this.filter = this.listenToFilterChange();
}
@ -51,12 +53,6 @@ export class ProductListComponent implements OnInit, AfterViewInit {
}
}
createForm() {
this.form = this.fb.group({
filter: '',
});
}
listenToFilterChange() {
return this.form
.get('filter')
@ -64,7 +60,9 @@ export class ProductListComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
this.route.data.subscribe((data: { list: Product[] }) => {
this.route.data.subscribe((value) => {
const data = value as { list: Product[] };
this.list = data.list;
});
this.dataSource = new ProductListDataSource(this.paginator, this.sort, this.filter, this.list);