Ritu Singh
Problem
I want to include matSort in the mat-table for the project I am working on. The table is working fine but the sort is not working. I have imported the MatSort module from @angular/material. This is the code implementation - HTML -
This is the .ts file. I have tried to write the code properly but no luck so far with the matSort working.
Solution
Your displayColumn should be:
You need also change your matColumnDef, e.g.
The mat-sort-header gets by defect the value of the displayColumns to order the columns. With your code Angular try to get, e.g. "Mobile No." as "field" to sort.
NOTE: Well, you can also use
But, better change the displayColumns :)
Suggested blogs:
>How can I access specific data inside a JSON file on an Angular?
>HTTP request after another but only care about first one in Angular?
>Why am I getting unexpected parent reaction to child button Angular?
>How can I combine multiple HTTP calls in Angular using RxJS?
>Why Ng serve doesn't work in Angulars?
>How to use JSON:API along with Angular/RxJs?
>Why Ng server doesn't work in Angulars?
>How to operate data before return it using Angular16?
>How to Embed Node Red into existing Angular application?
>Why Angular routing with mat-toolbar is not working?
>Update Observable with value from a different Observable in Angular
>P-Dropdown doesn't set Value manually with Reactive Form in Angular
>Why Apex stacked chart bar is not showing in the x-axis in Angular?
>How can I delete the 3rdpartylicenses.txt file in Angular?