user517406 user517406 - 2 years ago 104
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 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'"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download