<div ng-repeat="fod in form.order_details">
...
<td class="control-cell">
<span ng-class="{error: prForm['qty_'+$index].$error.required && showValidationMessages}">
<input type="number" name="{{'qty_' + $index}}" ng-model="fod.qty" ng-change="qtyPerKindCalc($index);" id="{{'qty_' + $index}}" required />
<span ng-show="prForm['qty_'+$index].$error.required && showValidationMessages" class="error-msg">This field required</span>
</span>
</td>
...
</div>
ngRepeat,其中我有必填字段。我有表單對象$ scope.prForm - 我在哪裏看到$錯誤。問題在於name =「{{'qty_'+ $ index}}」。在$ scope.prForm我是有場
{{'qty_' + $index}}: instantiate.c
但我需要
qty_0: instantiate.c
我怎麼能有好{{ 'qty_' + $指數}}中的name屬性操作?
'name =「qty _ {{$ index}}」'? – SET
動態名稱解決方案:http://stackoverflow.com/a/12044600/1005180 – user1005180