user517406 user517406 - 1 year ago 69
Javascript Question

Angular filter syntax

I am trying to filter some data on a string value but I can't get the syntax right. Here is my code :

<tbody ng-repeat="qbRating in vm.scope.qbRatings | filter:'tournament.season.seasonName':'2022' | ratingFilter | orderBy:'-rating'">
<tr class="qbrating2022">
<td>{{ qbRating.tournament.season.seasonName }}</td>
<td>{{ }}</td>
<td>{{ qbRating.completion }}</td>
<td>{{ qbRating.gain }}</td>
<td>{{ qbRating.touchdown }}</td>
<td>{{ qbRating.interception }}</td>
<td>{{ qbRating.rating }}</td>

The filter does not return any data even though it should do, but there is no error returned in the console.

Can anybody help me get the syntax right?

Answer Source

You should put filter on specific property by specifying object to be match like filter: {'tournament': {season : {seasonName:'2022'}}}

ng-repeat="qbRating in vm.scope.qbRatings | filter: {'tournament': {season : {seasonName:'2022'}}} | ratingFilter | orderBy:'-rating'"