4
IM在数据表中的工作角2角2 - * ngFor使用复选框和相应的标签
我<table-component>
是一个普通的<table>
和里面我想乘采用了棱角分明的* ngFor <tr>
S,像这样的:
<tr *ngFor="#person of persons; #i = index">
每<tr>
有几个字段和一个checkbox
有label
。
我设置了checkbox
的id属性,像这样:
<input type="checkbox" id="checkbox{{i}}">
<label for="checkbox{{i}}">{{person.finished}}</label>
凡{{我}}是从ngFor局部变量。它工作正常,但只适用于复选框。
当我尝试对label
中的atrribute“for”执行相同操作时,我只会收到错误消息。
Unhandled Promise rejection: Template parse errors:
Can't bind to 'for' since it isn't a known native property ("
<div>
<input type="checkbox" id="checkbox{{i}}">
<label [ERROR ->]for="checkbox{{i}}">{{person.finished}}</label>
</div>
</td>
我的问题是:
如何设置了“”使用角2的ngFor标签的属性,所以他们指向正确的复选框?