我在我的应用程序中使用了 Angular Material,我有两个mat-table
对单个组件进行排序,但我的排序仅适用于第一个表
这是ts代码
@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 #table1 [dataSource]="inventoryDataSource" matSort>
<mat-table #table2 [dataSource]="additionalDataSource" matSort>