After encountering issues with the Mat Table / Mat Paginator due to an ngIf in my HTML file, I had to readjust the component. The standard paginator convention didn't work as expected because of delayed data arrival. Below is the updated typescript that successfully implements pagination for ONE table.
Now, my challenge is to incorporate Mat Pagination for two tables within the same component. So far, I've only managed to make one table function properly. As a beginner in Angular, I'm seeking guidance on how to solve this issue. My research continues, but it seems that having multiple instances of Mat Pagination in a single component may not be possible based on my current understanding.
Here is the functional Typescript code:
dataSource1 = new MatTableDataSource<any>(this.userData());
dataSource2 = new MatTableDataSource<any>(this.userData2());
private paginator: MatPaginator;
@ViewChild(MatPaginator, { static: false }) set matPaginator(mp: MatPaginator) {
this.paginator = mp;
this.dataSource1.paginator = this.paginator;
}
ngOnInit() {
this.dataSource1.paginator = this.paginator;
}
My goal is to enable pagination for both dataSource1 and dataSource2. However, attempts to assign this.paginator to both tables in ngOnInit and ViewChild have disrupted pagination for each. I've double-checked my HTML structure and it appears to be correct.