我在AngularJS中生成动态表单:
<div ng-repeat="choice in myData" class='repeater'>
<div ng-if="choice.type === 'dropdown'" ng-init="count = 0">
<div class="row">
<div class="col-md-2">
<p>choose</p>
</div>
<div class="col-md-8">
<select ng-model="selected" ng-options="item.value for item in mydatedropdown[count]"> </select>
</div>
</div>
{{count += 1}}
</div>
</div>
我无法增加count的值并将其分配给mydatedropdown[]
。我是AngularJS的新手。
答案 0 :(得分:0)
您可以尝试将ng-repeat更改为<div ng-repeat="(index, choice) in myData" class='repeater'>
并使用index
中的mydatedropdown
<div ng-repeat="(index, choice) in myData" class='repeater'>
<div ng-if="choice.type === 'dropdown'" ng-init="count = 0">
<div class="row">
<div class="col-md-2">
<p>choose</p>
</div>
<div class="col-md-8">
<select ng-model="selected" ng-options="item.value for item in mydatedropdown[index]"> </select>
</div>
</div>
</div>
</div>