Viv*_*han 6 angularjs angularjs-ng-repeat angularjs-ng-model
我在我的一个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>
Run Code Online (Sandbox Code Playgroud)
secondN2.core.r1r2.value是一个数字,我通过在getNumber方法中返回新的Array(n)将它转换为数组,一个集合
在这种情况下如何给出合适的ng模型?以及如何检索值?
如果我尝试给予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>
Run Code Online (Sandbox Code Playgroud)
编辑:2
这是有效的:这是它的吸引力
Dar*_*rov 10
您可以在控制器中拥有一个包含所选值的数组:
$scope.values = [];
Run Code Online (Sandbox Code Playgroud)
然后将您的下拉列表绑定到此模型:
<select ng-model="values[i]" ng-change="calculate()">
<option value="1 Gig" selected="selected">1 Gig</option>
<option value="10 Gig">10 Gig</option>
</select>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7277 次 |
| 最近记录: |