@tonyasd2015 wrote:
I have a select control in my ionic - cordova app. Each option in select control has value and text which is loading with ng-repeat. When I set the ng-model initially the selection not changing. Please help me how to fix this. Below is the code I used;
<select ng-model="myselecteditem"> <option ng-repeat="item in myitemlist" value="{{item.value}}" >{{item.text}}</option> </select>
Below is the code in controllers.js
var item = {}; item.value = ""; item.text = "--SELECT--"; $scope.myitemlist.push(item); item = {}; item.value = "1"; item.text = "item 1"; $scope.myitemlist.push(item); item = {}; item.value = "2"; item.text = "item 2"; $scope.myitemlist.push(item); $scope.myselecteditem=$scope.myitemlist[2].value;
From the above code the selected item by default will be 'item2' But its '--SELECT--'. Not changing.
Posts: 2
Participants: 1