我正在研究复选框问题,我需要从mat-table的matHeaderCellDef绑定当前页面上所有行的索引值。有什么方法可以使用ngModel访问或绑定索引值到matHeaderCellDef
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 custom-table business-out">
</ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> {{indexValue}} </th>
</ng-container>
我已经尝试过类似的操作,但是不起作用
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 custom-table ten-four-col-unequal">
<ng-container matColumnDef="select">
<th mat-header-cell *matHeaderCellDef>
<mat-checkbox [ngModel]="dataSource.selected" (ngModelChange)="checkall($event,dataSource)" [disabled]="!form.valid" (change)="checkall($event,dataSource)"></mat-checkbox>
</th>
<td mat-cell *matCellDef="let element; let i = index">
<mat-checkbox [value]="element.question_id" [disabled]="!form.valid" [(ngModel)]="element.state" (change)="checkEach(element,i,$event,dataSource)"></mat-checkbox>
</td>
</ng-container>
</table>