How can I implement ng-class-odd in Aurelia

I want the odd table rows to be colored. Angular has ng-class-odd and ng-class-even that runs inside the ng-repeat scope.

Is there some way to get the index of the repeat function in Aurelia?

+3


source to share


1 answer


There are properties $even

and $odd

available for elements in the binding repeat.for

.

You can conditionally apply a class like this -



<ul>
  <li repeat.for="item of items" class="${ $even ? 'my-class': '' }"></li>
</ul>

      

+7


source







All Articles