0

is it possible to have a condition in a ng-repeat section ? I want the list to be reversed if the condition is true

<td ng-repeat="dataset in something.datasets if(true) { reverse }">
Anders Pedersen
  • 2,255
  • 4
  • 25
  • 49

1 Answers1

2

DEMO

You don't need a condition, you can use a filter for this which is orderBy

  <ul>
    <li ng-repeat='item in vm.items | orderBy: item : vm.reverse'>
      {{item}}
    </li>
  </ul>

if vm.reverse is true, it will display in the reverse order.

Documentation for orderBy

Louie Almeda
  • 5,366
  • 30
  • 38