0

I have an array of items which contains an array of other items. The user can filter these items filling a form in the interface. It's working, but now I have a filter that need to execute just for the first item of an array that is inside of these items. What "I want" to do is this:

<tr ng-repeat="item in items | filter: itemSearch | filter: {
                    my_object: { 
                        propertyA: items_filter.propertyA,
                        propertyB: items_filter.propertyB,
                        propertyC[0].status: items_filter.status //here
                    }
                }"></tr>

I'm getting the error:

vendor.min.js:16631 Error: [$parse:syntax] Syntax Error: Token '[' is unexpected, expecting [}] at column 401 of the expression [items | filter: itemsSearch | filter: {

How can I filter a property of the array's first item?

2
  • Like this?: stackoverflow.com/questions/20715726/… Commented Jan 31, 2017 at 17:14
  • 1
    this is a case that will require a custom filter; this logic is too complex for the stock filter filter. Commented Jan 31, 2017 at 17:15

1 Answer 1

0

I've created a custom filter based on this answer : https://stackoverflow.com/a/16479421/924002

So, the final code it will be:

<tr ng-repeat="item in items | filter: itemSearch | filter: {
                    my_object: { 
                        propertyA: items_filter.propertyA,
                        propertyB: items_filter.propertyB
                    }
                } | filter:criteriaMatch(items_filter.status)"></tr>
Sign up to request clarification or add additional context in comments.

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.