I have used Angular Material in my application and I have two mat-table
with sorting on single component but my sorting is working only on first table
here is ts code
@ViewChild(MatSort) inventoryDataSort: MatSort;
@ViewChild(MatPaginator) inventoryDataPaginator: MatPaginator;
@ViewChild(MatSort) additionalDataSort: MatSort;
@ViewChild(MatPaginator) additionalDataPaginator: MatPaginator;
ngAfterViewInit() {
this.inventoryDataSource.sort = this.inventoryDataSort;
this.inventoryDataSource.paginator = this.inventoryDataPaginator;
this.additionalDataSource.sort = this.additionalDataSort;
this.additionalDataSource.paginator = this.additionalDataPaginator;
}
mat-table
<mat-table #table1 [dataSource]="inventoryDataSource" matSort>
<mat-table #table2 [dataSource]="additionalDataSource" matSort>