I'm building a simple angular webapp (front only). How can I make a mat-table renders each time my array changes
my component:
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();
}
}
I've found a lot of solution but with old versions of angular that used deprecated functions. The Idea is to get a callback when array is updated to refresh table