How to pass data to material table data source dynamically

扶醉桌前 提交于 2019-12-02 08:25:34

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.

 <app-feed-list [feedsOverviewData]="this.feedsOverviewData"></app-feed-list>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!