madhur madhur - 1 year ago 140
Javascript Question

Using filter in ng-repeat

I am trying to use a filter with an expression in ng-repeat like this -

<div ng-repeat= "fruit in fruits | filter: {fruit.color !: 'red'}">
{{ fruit }}

But it doesn't seem to work, can someone confirm that it is possible to use expression in filters(I am using angular 1.0.8)

Answer Source

First thing you should upgrade you Angular Version to latest, it would not make sense to stay with Angular 1.0.x

<div ng-repeat= "fruit in fruits | filter: {color : '!red'}">
   {{ fruit }}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download