O
O
odd-look2015-02-04 10:53:14
Angular
odd-look, 2015-02-04 10:53:14

Is it possible to make an array iterate from the end with ng-repeat?

ng-repeat="item in items"
I want the output to start from the last element, not the first.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey K, 2015-02-04
@odd-look

ng-repeat="item in items.slice().reverse()"

T
TekVanDo, 2015-02-04
@TekVanDo

For versions higher than 1.3,
if the version is lower, you can write a directive like

app.filter('reverse', function() {
  return function(items) {
    return items.slice().reverse();
  };
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question