我正在使用Angularjs ng-Repeat添加复选框:
<div class="checkbox-circle" ng-repeat="t in tenders">
<input type="checkbox" checklist-model="contratacion.select" checklist-value="t.id" id="t.id">
<label for="t.id">{{t.name}}</label>
</div>
其中"招标"是具有"名称"one_answers" id"属性的数组。问题在于,输入的ID值没有通过循环变化,结果复选框具有相同的ID值。我是否将ID值错误地传递给输入?期望" t.id"更改输入ID是错误的吗?
使用非角度属性内部的相同的卷曲括号表示法,您将用于普通文本,即:
<div class="checkbox-circle" ng-repeat="t in tenders">
<input type="checkbox" checklist-model="contratacion.select" checklist-value="t.id" id="{{t.id}}">
<label for="{{t.id}}">{{t.name}}</label>
</div>
是的,你会错;这是因为ID是t.id
仅仅是一个标准属性。要使Angular将此值转换为预期的ID,您需要使用插值:id="{{t.id}}"
。
您尝试使用的方法是一个角度表达式,仅适用于某些属性,该属性(例如checklist-value
)允许使用该属性。否则,您需要使用{{<expression>}}
来评估您的价值。