user517406
user517406

Reputation: 13773

AngularJS filter on deep properties

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?

Upvotes: 2

Views: 204

Answers (2)

Pankaj Parkar
Pankaj Parkar

Reputation: 136144

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

Upvotes: 3

finico
finico

Reputation: 711

filter takes a string, object or function, not an array filter api

Upvotes: 0

Related Questions