Answer the question
In order to leave comments, you need to log in
Angular, orderBy and one dimensional array?
Good afternoon,
I know that the orderBy filter can sort associative arrays, but how to sort alphabetically a one-dimensional array like ['Vasya', 'Petya', 'Anya'] ?
...ng-repeat="name in names | orderBy: 'что написать тут?'">
Answer the question
In order to leave comments, you need to log in
stop trying to do everything in html markup.
function MyController (names) {
this.names = names.sort();
}
<ul ng-controller="MyController as my">
<li ng-repeat="name in my.names">{{name}}</li>
</ul>
So what's the problem? Well, you wrote... Let's say there is a FIO field, then add
ng-repeat="name in my.names | orderBy: 'FIO'"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question