I want to pass the dynamic data to material table. I show my code:
parent.component.html
-
you can use it like this: create a new DataSource based on a copy of the data (for immutability)
this.dataSource = new MatTableDataSource([...<[whatever incoming data]>);
try this (for your case)
this.feedsService.getFeedsByVin(this.vin).subscribe((data) => {
this.feedsOverviewData = [...data];
});
(similar setup for ngOnInit)
ngOnChange() {
console.log(this.feedsOverviewData);
this.dataSource = new MatTableDataSource(this.feedsOverviewData);
}
the subscribe works in its own async process with the data only available there. angular does some things behind the scenes to make this work.
讨论(0)