3

I created two custom filters and try to use both in ng-repeat.

How can i pass result of first filter as a input for second filter?

I tried as(alias) in ng-repeat but it not works,

<input type="text" ng-model = "ageLimit" />
<input type="text" ng-model = "lastSeen" />
<div ng-repeat = "member in lists | ageFilter:ageLimit:lists as results | LastSeenFilter:lastSeen:results">

Error message

Error: [ngRepeat:badident] alias ' results | LastSeenFilter:lastSeen:results' is invalid --- must be a valid JS identifier which is not a reserved name. http://errors.angularjs.org/1.3.0/ngRepeat/badident?p0=results%20%7C%20LastSeenFilter%3AselectLastSeen%3Aresults

2
  • Simply chaining/piping the two filters should to it, no? member in lists | ageFilter:ageLimit | LastSeenFilter:lastSeen Commented Oct 30, 2014 at 5:29
  • Its not working, chaining works for first time but when i change params to filter it apply to previous result(it apply filter in first filtered set not the whole set) Commented Oct 30, 2014 at 6:32

2 Answers 2

1

the problem is in the "as". since i have the same problem i looked inside the ngRepeadDirective and found out that the regex there that breaks the expression does not support filters after alias as can be seen here.

Sign up to request clarification or add additional context in comments.

3 Comments

Don't you have solution for it? I need first filter for paging (total records, so on), and second filter to display.
no, there is no solution for that, but for paging there is are great solution and directives such as brantwills.github.io/Angular-Paging , and you can google for more, pagination is just a thing to learn and its easy
Yeah, I know, just want to try new way. I've already changed to another way for it. Thanks!
0

You can chain filters in Angular. The output of the first filter will act as input to the second one, and so on.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.