Reputation: 33
function buildControl($scope){
$scope.test_obj = {
used:3,
data:[{id:1},{id:2},{id:3},{id:4}]
};
}
<div ngApp>
{{test_dict.used}}
<select ng-model="test_obj.used">
<option ng-repeat=" d in test_obj.data" value="{{d.id}}">{{d.id}}</option>
</select>
</div>
why the selector always select the first option while I expect it will select the third one which's value equal 3?
Upvotes: 3
Views: 1333
Reputation: 2557
Use ng-value
instead.
http://jsfiddle.net/bateast/LsEL5/
HTML:
<option ng-repeat=" d in test_obj.data" ng-value="d.id">{{d.id}}</option>
JS:
function buildControl($scope){
$scope.test_obj = {
used:3,
data:[{id:1},{id:2},{id:3},{id:4}]
};
}
Upvotes: 6