我正在尝试过滤字符串值的一些数据,但我无法获得正确的语法。这是我的代码:
<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>
过滤器没有返回任何数据,即使它应该返回,但控制台中没有返回任何错误。
任何人都可以帮我纠正语法吗?
最佳答案
您应该通过指定要匹配的对象来对特定属性进行过滤,例如 filter: {'tournament': {season : {seasonName:'2022'}}}
ng-repeat="qbRating in vm.scope.qbRatings | filter: {'tournament': {season : {seasonName:'2022'}}} | ratingFilter | orderBy:'-rating'"
关于javascript - AngularJS 过滤深层属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36669560/