【发布时间】:2019-04-19 12:40:46
【问题描述】:
而不是向表格显示数据的常规方式。我正在尝试创建我的自定义表组件并通过 .
将数据投影到材料表中像这样:
<table mat-table [dataSource]="dataSource">
<!-- I want to Render the header and cell data here -->
<ng-content></ng-content>
<mat-header-row *matHeaderRowDef="headers; sticky: true"></mat-header-row>
<mat-row *matRowDef="let row; columns: headers;"></mat-row>
</table>
所以我可以这样调用这个自定义组件:
<app-customized-table>
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef> Id </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.Id}} </mat-cell>
</ng-container>
...etc
</app-customized-table>
但是,它不会检测到内容。这是我正在尝试做的一个 stackblitz 示例。
https://stackblitz.com/edit/angular-qwvcln?file=src%2Fapp%2Fcustom-table.component.ts
有没有办法做到这一点?
谢谢。
【问题讨论】: