Updated to angular 11
Now compiling with strict mode in typescript Need to error checking now
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
Update Order
|
||||
</button>
|
||||
<!-- This should check filtered data and not data-->
|
||||
<button mat-button mat-icon-button (click)="exportCsv()" [disabled]="!(data | async).length">
|
||||
<button mat-button mat-icon-button (click)="exportCsv()" [disabled]="!(data | async)?.length">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
<a mat-button [routerLink]="['/products', 'new']">
|
||||
|
||||
@ -18,12 +18,12 @@ import { ProductListDataSource } from './product-list-datasource';
|
||||
styleUrls: ['./product-list.component.css'],
|
||||
})
|
||||
export class ProductListComponent implements OnInit {
|
||||
dataSource: ProductListDataSource;
|
||||
filter: BehaviorSubject<string>;
|
||||
filter: BehaviorSubject<string> = new BehaviorSubject('');
|
||||
data: BehaviorSubject<Product[]> = new BehaviorSubject<Product[]>([]);
|
||||
dataSource: ProductListDataSource = new ProductListDataSource(this.filter, this.data);
|
||||
form: FormGroup;
|
||||
list: Product[];
|
||||
data: BehaviorSubject<Product[]>;
|
||||
menuCategories: MenuCategory[];
|
||||
list: Product[] = [];
|
||||
menuCategories: MenuCategory[] = [];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = [
|
||||
'name',
|
||||
@ -44,8 +44,6 @@ export class ProductListComponent implements OnInit {
|
||||
this.form = this.fb.group({
|
||||
menuCategory: '',
|
||||
});
|
||||
this.filter = new BehaviorSubject(undefined);
|
||||
this.data = new BehaviorSubject([]);
|
||||
this.data.subscribe((data: Product[]) => {
|
||||
this.list = data;
|
||||
});
|
||||
@ -57,7 +55,8 @@ export class ProductListComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.dataSource = new ProductListDataSource(this.filter, this.data);
|
||||
this.route.data.subscribe((data: { list: Product[]; menuCategories: MenuCategory[] }) => {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Product[]; menuCategories: MenuCategory[] };
|
||||
this.loadData(data.list, data.menuCategories);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user