I have a list of data coming from the backend, and I want to update the select value in the view, which for some reason does not happen.
I tried ng-selected, which works inefficiently, sometimes the model does not update spmetimes.
here is my code, can anyone help?
<div class="listitem" ng-repeat="d in data">
{{d.name}}:
<select
ng-model="d.option"
ng-options="d.name for d in options"></select>
</div>
controller
var myApp = angular.module('myApp', []);
myApp.controller("SomeController", function($scope) {
$scope.options = [{
"id": "id1",
"name": "p1"
}, {
"id": "id2",
"name": "p2"
}];
$scope.data = [{
"name": "data1",
"option": {
"id": "id1",
"name": "p1"
}
}];
});
http://jsfiddle.net/gFCzV/58/
source
share