I am trying to get the mat-table sorting to work locally, and while I can get the data to show up as expected, clicking on the header row does not do the sortin
My solution for this problem is as below -
1. These two lines will go in the same order.
this.dataSource = new MatTableDataSource(myRowDataArray);// this dataSource is used in table tag.
this.dataSource.sort = this.sort;
2. Pass MatTableDataSource object in [dataSource]
// rest of the table definition here
3. By default, the MatTableDataSource sorts with the assumption that the sorted column's name matches the data property name that the column displays.
Example -
Date
{{row.date|date}}
4. If the table is inside *ngIf,then replace it with [hidden] or some other filter.
I missed the 2nd point.
Cheers!