user517406 user517406 - 7 months ago 20
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>{{ qbRating.team.teamName }}</td>
<td>{{ qbRating.completion }}</td>
<td>{{ qbRating.gain }}</td>
<td>{{ qbRating.touchdown }}</td>
<td>{{ qbRating.interception }}</td>
<td>{{ qbRating.rating }}</td>
</tr>
</tbody>


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

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'"