Angular 如何获取索引值作为div的id?
目前我正在使用Angular 2.0。我有一个数组叫做addExtra:number[]=[0,1,2,3] 我的html代码如下:Angular 如何获取索引值作为div的id?,angular,typescript,Angular,Typescript,目前我正在使用Angular 2.0。我有一个数组叫做addExtra:number[]=[0,1,2,3] 我的html代码如下: <div *ngFor="let val of addExtra"> <div class="row"> <div style="margin-left:15px;"> <button class="btn btn-danger btn-delete"
<div *ngFor="let val of addExtra">
<div class="row">
<div style="margin-left:15px;">
<button class="btn btn-danger btn-delete"
(click)='delete(val)'>
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<label for="isCheckBox">Draw</label>
<input id="isCheckBox" id=val type="checkbox" class="setCheckbox" (change)="isChecked($event)" style="vertical-align: text-bottom;" />
</div>
</div>
</div>
画
如何将val表示的0、1、2、3作为复选框的id。
<input id="{{val}}" type="checkbox" class="setCheckbox" (change)="isChecked($event)" style="vertical-align: text-bottom;" />
<input id={{val}} type="checkbox" class="setCheckbox" (change)="isChecked($event)" style="vertical-align: text-bottom;" />
画
html标记不能有2个id
<input id={{val}} type="checkbox" class="setCheckbox" (change)="isChecked($event)" style="vertical-align: text-bottom;" />