Answer the question
In order to leave comments, you need to log in
How to sort multiple elements by different keys in ng-repeat -> orderBy?
Link to JSFiddle .
For example, there is an array of users, firstName and lastName.
When rendering them in the frontend using ng-repeat, I sort them by the key firstName . But here are some of them that need to be sorted by lastName.
So now the result is this.
$scope.users = [{
firstName: 'AAA',
lastName: 'AAA'
}, {
firstName: 'BBB_test',
lastName: 'EEE'
}, {
firstName: 'CCC',
lastName: 'CCC'
}, {
firstName: 'DDD_test',
lastName: 'WWW'
}];
// output
AAA
BBB_test
CCC
DDD_test
// Expect Result
AAA
CCC
BBB_test
DDD_test
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question