【发布时间】:2015-05-01 07:24:07
【问题描述】:
我的一个 div 中有一个下拉列表,我从中选择要在第二个 div 中的下拉列表的数量。我的任务是能够从第二个 div 内的每个下拉列表中选择不同的值。这是我正在尝试的代码
<div ng-repeat="i in getNumber(secondN2.core.r1r2.value) track by $index">
<div>
<strong><u>For Core link number {{$index+1}}:</u> </strong><br>
<strong>Select IM</strong>
<select ng-model="im" ng-change="calculate()" >
<option value="1 Gig" selected="selected">1 Gig</option>
<option value="10 Gig">10 Gig</option>
</select><br>
</div>
</div>
secondN2.core.r1r2.value 是一个数字,我通过在 getNumber 方法中返回 new Array(n) 将其转换为数组,一个集合
在这种情况下如何给出正确的 ng-model ?以及如何检索这些值?
如果我尝试给i.im,它仍然没有帮助。随着im,$scope.im 即将到来undefined
更新
什么是两个嵌套循环
<div ng-repeat="j in secondN3.core" style="border:1px solid;">
<strong>Configure Core Links between {{j.name}}</strong><br><br>
<div ng-repeat="i in getNumber(j.value) track by $index">
<div>
<strong><u>For Core link number {{$index+1}}:</u> </strong><br>
<strong>Select IM</strong>
<select ng-model="secondN3.coreValues[[$parent.$index,$index]]" ng-change="calculate()" >
<option value="1 Gig" selected="selected">1 Gig</option>
<option value="10 Gig">10 Gig</option>
</select><br>
</div>
</div>
<div>
编辑:2
这行得通:This 是它的 plunker
【问题讨论】:
标签: angularjs angularjs-ng-repeat angularjs-ng-model