如何在物料排序中使用"id"来注入动态值?当我尝试使用插值 mat-sort-header 导致错误时 - 't bind to ' mat-sort-header ' since it isn' t 'th'的已知属性
该表是动态构建的 .
<table matSort (matSortChange)="sortData($event)">
<tr>
<th mat-sort-header="{{mapped.id}}" id="{{mapped.id}}">{{mapped.header}}</th>
</tr>...
</table>
我正在使用 import from '@angular/material';
它取自https://material.angular.io/components/sort/overview
非常感谢
2 回答
试试这个:
您可能忘记添加MatSortModule .
每当你看到类似的东西:
这表示您没有添加模块 .
另外一种更有角度的写作方式是: