我正在构建一个简单的 angular webapp(仅限前端)。每次我的数组更改时,如何制作一个 mat-table 渲染
我的组件:
export class TableViewComponent implements OnInit {
  dataSource: MatTableDataSource<Process>;
  processes: Process[];
  constructor(private processesService: ProcessesService, private router: Router) { }
  ngOnInit(): void {
    this.getProcesses();
    this.dataSource = new MatTableDataSource(this.processes);
    //HERE I'ld like to watch for this.processes changes and change datasource
  }
  getProcesses(): void {
    this.processes = this.processesService.getProcesses();
  }
}
我找到了很多解决方案,但是旧版本的 angular 使用了已弃用的函数。想法是在更新数组以刷新表时获取回调