Edgar Martinez Edgar Martinez - 23 days ago 6
Javascript Question

Can I filter ng-repeat with the $odd or $even properties?

I am trying to auto filter an

ng-repeat
list by even index. Is it possible to do this somehow? Here's what I am trying but it isn't working:

<div data-ng-repeat="thing in things | filter:$even" >
<div>{{thing.name}}</div>
</div>


Is there a proper way of achieving this?

Answer

This will show $even names of the things list.

<div ng-repeat="thing in things" ng-if="$even">
    {{thing.name}}
</div>