我正在尝试过滤字符串值上的一些数据,但我无法正确使用语法。这是我的代码:
<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>
过滤器不会返回任何数据,即使应该这样做,但控制台中没有返回错误。
有人可以帮助我正确理解语法吗?
答案 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