Why does ng-selected not work with ng-repeater?
angularjs
Solution
stick with `ng-options`
<div ng-app>
<h2>Todo</h2>
<div ng-controller="QuarterController">
<select name="quarter" ng-model="Quarter" ng-options="obj.value as obj.text for obj in [{'value': 1,'text' : 'Q1'},{'value':2,'text':'Q2'},{'value':3,'text':'Q3'},{'value':4,'text':'Q4'}]">
</select>
</div>
</div>
function QuarterController($scope) {
$scope.Quarter = 2;
}
http://jsfiddle.net/hDNsm/3/
you might as well define the array in your controller
Problem
Why is this repeater broken ``` <select name="quarter" ng-model="Quarter" ng-selected="Quarter" > <option ng-repeat="v in [1,2,3,4]" value="{{v}}">Q{{v}}</option> </select> ``` But not the handwritten way? ``` <select name="quarter" ng-model="Quarter" ng-change="onQuarterChange()" ng-selected="Quarter"> <option value="1">Q1</option> <option value="2">Q2</option> <option value="3">Q3</option> <option value="4">Q4</option> </select> ```