I have 2 material 2 tables in the same component with sorting. I cannot find a way to assign the MatSort directive to its own table. I\'m only able to use MatSort on the fir
Edit:
I believe you need:
@ViewChild(MatSort) sort: MatSort;
above your:
@ViewChild('hBSort') hBSort: MatSort;
@ViewChild('sBSort') sBSort: MatSort;
Then:
ngAfterViewInit() {
this.hBSource.sort = this.sort;
this.sBSource.sort = this.sort;
}
Assuming that your HBDataSource and SBDataSource both export MatTableDataSource();
I'm referencing these sources:
https://material.angular.io/components/sort/overview https://github.com/angular/material2/blob/master/src/demo-app/table/table-demo.ts