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?

Lücks
  • 3,806
  • 2
  • 40
  • 54
  • Like this?: http://stackoverflow.com/questions/20715726/how-to-call-one-filter-from-another-filter-in-angular-js – lplatz Jan 31 '17 at 17:14
  • 1
    this is a case that will require a custom filter; this logic is too complex for the stock `filter` filter. – Claies Jan 31 '17 at 17:15

1 Answers1

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>
Community
  • 1
  • 1
Lücks
  • 3,806
  • 2
  • 40
  • 54