gpt4 book ai didi

javascript - name 属性中的 angular ngRepeat $index

转载 作者:搜寻专家 更新时间:2023-11-01 05:01:03 26 4
gpt4 key购买 nike

<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 - 我在其中看到 $error。问题出在 name="{{'qty_' + $index}}"中。在 $scope.prForm 我有字段

{{'qty_' + $index}}: instantiate.c

但我需要

qty_0: instantiate.c

如何在名称属性中进行良好的 {{'qty_' + $index}} 操作?

最佳答案

非常简单:

name="qty_{{$index}}"

这是一个plunk看看它是如何工作的。

关于javascript - name 属性中的 angular ngRepeat $index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21631456/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com