admin管理员组文章数量:1341736
<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, where i'm have required field. I'm have form object $scope.prForm - where i'm see $error. Problem is in name="{{'qty_' + $index}}". In $scope.prForm i'm have field
{{'qty_' + $index}}: instantiate.c
but i'm need
qty_0: instantiate.c
How I can have good {{'qty_' + $index}} operation in name attribute?
<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, where i'm have required field. I'm have form object $scope.prForm - where i'm see $error. Problem is in name="{{'qty_' + $index}}". In $scope.prForm i'm have field
{{'qty_' + $index}}: instantiate.c
but i'm need
qty_0: instantiate.c
How I can have good {{'qty_' + $index}} operation in name attribute?
Share asked Feb 7, 2014 at 15:22 user1005180user1005180 811 gold badge1 silver badge10 bronze badges 2-
name="qty_{{$index}}"
? – SET001 Commented Feb 7, 2014 at 15:31 - 1 Solution with dynamically names: stackoverflow./a/12044600/1005180 – user1005180 Commented Feb 7, 2014 at 16:15
2 Answers
Reset to default 9Very easy:
name="qty_{{$index}}"
Here is a plunk to see how it work.
Try this:
id="qty_{{$index}}"
:)
本文标签: javascriptangular ngRepeat index in name attributeStack Overflow
版权声明:本文标题:javascript - angular ngRepeat $index in name attribute - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743683743a2521550.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论