I have the following DATA:
const ELEMENT_DATA: Element[] = [
{position: 1, company:{id:1, name:"fox"}},
{position: 2, company:{id:2, name:"mercadona"}},
];
I show it using <mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="position">
<mat-header-cell *matHeaderCellDef mat-sort-header> No. </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.position}} </mat-cell>
</ng-container>
<!-- Company Column -->
<ng-container matColumnDef="company">
<mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.**company.name**}} </mat-cell>
</ng-container>
and in the TS I place the displayedCOlum correctly
displayedColumns = ['position', 'company'];
I can sort the Position field, but not Company field
I know that the matColumnDef must be called the same as the field of the class, but in this case it is impossible for me because the field I show on the screen is called COMPANY.NAME, what is the solution to this case?