How to add data dynamically to mat-table dataSource?

后端 未结 7 1467
既然无缘
既然无缘 2020-12-08 06:39

I have data streaming from backend and i see it printing in console now i am trying to push event to dataSource its throwing error dataSource is not defined. Ca

7条回答
  •  情深已故
    2020-12-08 07:09

    For me, nothing of these answers didn't work. I had an observable that I subscribe to get new data. the only solution that works for me was:

     this.dataService.pointsNodesObservable.subscribe((data) => {
      this.dataSource = new InsertionTableDataSource(this.paginator, this.sort, this.dataService);
      this.dataSource.data = data;
    });
    

    render like a charm!

提交回复
热议问题