1

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 }}
</div>

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)

2 Answers 2

3

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 : '!' + selected Color}">
   {{ fruit }}
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

works like a charm, In my case I have used it as a variable <div ng-repeat= "fruit in fruits | filter: {color : '!' + colorToleave}"> {{ fruit }} </div>
0

This is just example of filter in ng-repeat:

<div ng-repeat= "fruit in fruits" >
     {{ fruit | uppercase}} 
</div>

$scope.fruits  = ['apple','banana']

OutPut:

APPLE
BANANA

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.