I would like to order the <option>
s of a <select>
by the values of an object, using ng-options
.
function Ctrl($scope) {
$scope.people = {'A1': 'Adam Smith', 'A2': 'Adam Adams'};
}
<select ng-model="selected"
ng-options="name for (userid, name) in people | orderBy:'name'"
></select>
However, the orderBy
filter doesn't seem to have any effect.
Expected output:
...
<option ...>Adam Adams</option>
<option ...>Adam Smith</option>
...
Actual output:
...
<option ...>Adam Smith</option>
<option ...>Adam Adams</option>
...
How can I use ng-options
to produce the Expected output?
I'm using Angular 1.3