I have a dropdown in one of my div, from which I am selecting the number of dropdowns to be in second div. My task is to be able to select the different values from each of the dropdowns inside the second div. Here is the code I am trying
<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
is a number, I am converting it to array,a collection, by returning new Array(n), in the getNumber
method
How to give the proper ng-model in this case? And how to retrieve the values?
If I try to give i.im
, it still does not help. With im
, $scope.im
is coming undefined
Updated
What is two nested loops are there
<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>
Edit:2
This is working: This is the plunker for that
You could have an array in your controller that will hold the selected values:
$scope.values = [];
and then bind your dropdowns to this model:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With