Here is my angular code:
<li ng-repeat="(key, value) in list | orderBy:customOrderFn">
<span>{{key}}: {{value.age}}</span>
</li>
app.controller('ListController', function ($scope) {
$scope.list = {
'name1': {
age: 22
},
'name2': {
age: 21
},
'name3': {
age: 23
}
}
$scope.customOrderFn = function (person) {
console.log(person);
return person.age;
}
I want to order by each person's age, so I using a custom order function. But this seems doesn't work.
So what's is wrong with my code? How can I fix it?