我试图在芯片上设置一个删除按钮,所以我尝试了:
<mat-chip-list>
<mat-chip *ngFor="let condition of conditions; let i = index">
{{condition.column.friendlyName}} {{condition.operator.symbol}} {{condition.value}}
<mat-icon class="close-icon" (click)="removeChip(i)">highlight_off</mat-icon>
</mat-chip>
</mat-chip-list>
但是它表示i
未定义。单击该索引可获得筹码索引的正确方法是什么?
答案 0 :(得分:0)
此内容以5度以上的角度更新为index as i
:
<mat-chip *ngFor="let condition of conditions; index as i">
{{condition.column.friendlyName}} {{condition.operator.symbol}} {{condition.value}}
<mat-icon class="close-icon" (click)="removeChip(i)">highlight_off</mat-icon>
</mat-chip>