Seva2015-08-01 14:15:42
Seva, 2015-08-01 14:15:42

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: 'что написать тут?'">

Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Sergey, 2015-08-01
Protko @Fesor

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>

Roman Rakzin, 2015-08-01

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 question

Ask a Question

731 491 924 answers to any question