在 Angular Material 上为 mat-table 添加页脚时,出现此错误:
column.footerCell 未定义
下面是我的代码:
<table mat-table [dataSource]="people" class="mat-elevation-z8">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let element">
<strong>{{ element.name }}</strong>
</td>
<td mat-footer-cell *matFooterCellDef> {{ people.length }} people</td>
</ng-container>
...
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
</table>
数据如下所示:
public displayedColumns = ['name'];
public people = [
{id: 1, name: 'John'},
{id: 2, name: 'Jane'},
{id: 3, name: 'Joe'},
];
如果我删除页脚代码,一切正常。对此有什么想法吗?