I am trying to enable sorting on a mat-table
, and I understood that *matColumnDef
and the binding element must have the same name.
In my case I need to call a getter on the element.
How can I handle this? Can I define an alias?
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> NAME </th>
<td mat-cell *matCellDef="let person"> {{person.getName()}} </td>
</ng-container>
Could I alias person.getName()
to name
somewhere so it will match matColumnDef
?
EDIT:
I tried something like bellow, but it doesn't work:
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> NAME </th>
<td mat-cell *matCellDef="let person; let name = person.getName()"> {{name}} </td>
</ng-container>