Getting multiple select values โ€‹โ€‹inside a single ng-repeat

I have a dropdown in one of my divs from which I select the number of dropdowns to be in the second div. My task is to be able to select different values โ€‹โ€‹from each drop-down list in the second div. Here is the code I'm 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 convert it to an array, a collection, returning a new array (n) in the getNumber method

How to give the correct ng-model in this case? And how to get the values?

If I try to give i.im , it still will not help. When im , $scope.im goes undefined

Update

What are two nested loops 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

It works: It is a plunker for this

+6
source share
1 answer

You may have an array in the 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> 
+10
source

Source: https://habr.com/ru/post/983154/


All Articles