Bob*_*ino 1 angular-material angular mat-table
在 Angular Material 上为垫子表添加页脚时,出现以下错误:
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>
Run Code Online (Sandbox Code Playgroud)
数据如下:
public displayedColumns = ['name'];
public people = [
{id: 1, name: 'John'},
{id: 2, name: 'Jane'},
{id: 3, name: 'Joe'},
];
Run Code Online (Sandbox Code Playgroud)
如果我删除页脚代码,一切都会正常。对此有什么想法吗?
您的其他 ng-container 中一定缺少此代码部分
<ng-container>
...
<td mat-footer-cell *matFooterCellDef></td>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
即使您不喜欢某些页脚列中的任何数据或信息,也必须包含此指令
| 归档时间: |
|
| 查看次数: |
4021 次 |
| 最近记录: |