I am trying to create a simple AngularJS filter on a list. However the element I want to filter on is a sub-element in an array.
(JSFIDDLE)
The objects:
elements = [{
'claim': [{value:'foo'}],
class: 'class1',
subject: 'name1'
}, {
'claim': [{value:'bar'}],
class: 'class1',
subject: 'name2'
}, {
'claim': [{value:'baz'}],
class: 'class1',
subject: 'name2'
}, {
'claim': [{value:'quux'}],
class: 'class1',
subject: 'name3'
}];
HTML:
<tr class='claimrow'
data-ng-repeat='c in elements | filter:{claim[0].value:srcBoxFilter} | orderBy: "claim[0].value" '>
The order by handles the syntax "claim[0].value" but the filter does not.
This generates an error:
Error: Syntax Error: Token '[' is unexpected, expecting [:]
at column 25 of the expression
[elements | filter:{claim[0].value:srcBoxFilter} | orderBy: "claim[0].value"]
starting at [[0].value:srcBoxFilter} | orderBy: "claim[0].value"].