Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何获取索引值作为div的id?_Angular_Typescript - Fatal编程技术网

Angular 如何获取索引值作为div的id?

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"

目前我正在使用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"
            (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;" />