我即将动态绑定
mat-table
中的组标题行。但是DOM
找不到headerId。
HTML:
<ng-container *ngFor="let result of headerData; let i = index">
<ng-container [matColumnDef]="header-row-'+i+'-group">
<th mat-header-cell *matHeaderRowDef
[style.text-align]="center"
[attr.colspan]=result.Count>
{{result.Name}}
</th>
</ng-container>
</ng-container>
<tr mat-header-row *matHeaderRowDef="groupHeaderColumns"></tr>
<tr mat-header-row *matHeaderRowDef="columnNames"></tr>
打字稿:
this.groupHeaderColumns = ['header-row-1-group', 'header-row-2-group']
试过了,
错误:
Couldnot find the header with id header-row-1-group
我哪里错了,我应该做什么改变?
尝试以下更改,您需要连接字符串
<ng-container [matColumnDef]="'header-row-'+i+'-group'">