假设我有以下对象数组:
$scope.users = [{id: 1, username: "jon", expired: true},
{id: 2, username: "adam", expired: false},
{id: 3, username: "jeff", expired: false}]
我正在尝试构建一个在过期帐户上过滤的表格:
<table class ="table table-bordered">
<tr>
th>ID</th>
<th>Username</th>
</tr>
<tr ng-repeat="x in users |filter: x.expired == true">
<td>{{ x.id }}</td>
<td>{{ x.username }}</td>
</tr>
</table>
但是上表是空白的。我该如何修复过滤器?
答案 0 :(得分:2)
过滤器表达式应该作为对象放置。
ng-repeat="x in users | filter: { expired : true}"