AngularJS过滤深度属性

时间:2016-04-16 20:48:00

标签: javascript angularjs angularjs-ng-repeat angularjs-filter

我正在尝试过滤字符串值上的一些数据,但我无法正确使用语法。这是我的代码:

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

过滤器不会返回任何数据,即使应该这样做,但控制台中没有返回错误。

有人可以帮助我正确理解语法吗?

2 个答案:

答案 0 :(得分:3)

您应该通过指定要匹配的对象(例如filter: {'tournament': {season : {seasonName:'2022'}}}

)来对特定属性进行过滤
ng-repeat="qbRating in vm.scope.qbRatings | filter: {'tournament': {season : {seasonName:'2022'}}} | ratingFilter | orderBy:'-rating'"

答案 1 :(得分:0)

filter接受字符串,对象或函数,而不是数组filter api