Suppose I have the following users:
$scope.users = {
"2": {
email: 'john@gmail.com',
name: 'John'
},
"3": {
email: 'elisa@gmail.com',
name: 'Elisa'
}
}
I would like to create a <select>
with the following options:
<option value="3">Elisa</option>
<option value="2">John</option>
In other words, users should be sorted by name.
I tried the following using the (key, value) in expression
syntax, but it doesn't work:
<option ng-repeat="(user_id, user) in users | orderBy:'user.name'"
value="{{ user.id }}">
{{ user.name }}
</option>
What am I missing?
Please do not suggest solutions with ng-options
as I use ui-select2
which is incompatible with ng-options
.