1

I have set my ng-repeat in options along with ng-selected, but option is not getting selected, When I remove ng-model from select all become working.

HTML code:

<select ng-model="formData.value">
<option value="{{item.value}}" ng-selected="{{((item.value).indexOf(formData.value) != -1 ? true:'')  == formData.value}}" ng-repeat="item in levels">{{ item.name}}</option>
</select>

Controller code:

$scope.levels= [
{"value": ["1", "2", "3"],"name": "High"}, 
{"value": ["4", "5", "6"],"name": "Medium"},
{"value": ["7", "8", "9"],"name": "Low"}
]

What I am doing here is, if the formData.value is between 1 to 3, i would like to show the dropdown field with High...

Its working fine without ng-model name, however I would like to get a value from the user and save it in the array. In that scenario, the dropdown doesn't show the selected field...

georgeawg
  • 48,608
  • 13
  • 72
  • 95
rajadurai
  • 11
  • 2
  • I have fixed the issue myself. I passed the input as a string and removed checking the form data value in the ng-selected... – rajadurai Aug 27 '17 at 11:21
  • Possible duplicate of [AngularJS: ng-selected doesn't show selected value](https://stackoverflow.com/questions/50804938/angularjs-ng-selected-doesnt-show-selected-value) – georgeawg Jun 11 '18 at 23:24

0 Answers0