angularjs - select in ng-option does not update -
i have list of data coming backend , want update select value in view not happening reason.
i tried ng-selected
not works efficiently, sometime model update spmetimes not.
here code, can help?
<div class="listitem" ng-repeat="d in data"> {{d.name}}: <select ng-model="d.option" ng-options="d.name 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" } }]; });
you need use select label group group value in array track trackexpr
, read docs
ng-options="option.name option in options track option.id"
demo, note not work in angualrjs 1.1
Comments
Post a Comment