如何在对象字段的 ng-repeat 中应用过滤器?
How to apply filter in ng-repeat for object's fields?
我想为 selected 对象字段应用 angular 过滤器。我有状态列表 ["waiting"、"conform"、"rac"],当我 select 状态时,它应该提供 table 中具有该状态的人的信息状态。
例如,如果某些人票符合,那么当我们select status = conform
时,只有显示的人应该有符合票。同样等待和 rac
请查看演示和代码。它不工作。请帮忙..
Please see the demo
HTML
<div class="col-md-12">
<table>
<thead>
<tr>Name</tr>
<tr>Status</tr>
</thead>
<tbody >
<tr ng-repeat="person in list| filter: status">
<td>{{person.name}}</td>
<td>{{person.status}}</td>
</tr>
</tbody>
</table>
</div>
控制器:
$scope.status_list=["waiting", "conform", "rac"];
$scope.list = [
{ 'name': 'A',
'status':'waiting'
},
{ 'name': 'B',
'status':'conform'
},
{ 'name': 'C',
'status':'rac'
}
]
<tr ng-repeat="person in list| filter: status">
你拼错了
具体应用 filter
over status
属性 而不是直接使用将作为包含过滤器工作的过滤器(使用压缩器设置为 true
以获得精确匹配).通过包含过滤器,您将获得列表中的人,该人的名字是您正在搜索的任何一个字符串 status
<tr ng-repeat="person in list| filter: { status: status}: true">
<td>{{person.name}}</td>
<td>{{person.status}}</td>
</tr>
Correct typo of ng-repead
to ng-repeat
我想为 selected 对象字段应用 angular 过滤器。我有状态列表 ["waiting"、"conform"、"rac"],当我 select 状态时,它应该提供 table 中具有该状态的人的信息状态。
例如,如果某些人票符合,那么当我们select status = conform
时,只有显示的人应该有符合票。同样等待和 rac
请查看演示和代码。它不工作。请帮忙.. Please see the demo
HTML
<div class="col-md-12">
<table>
<thead>
<tr>Name</tr>
<tr>Status</tr>
</thead>
<tbody >
<tr ng-repeat="person in list| filter: status">
<td>{{person.name}}</td>
<td>{{person.status}}</td>
</tr>
</tbody>
</table>
</div>
控制器:
$scope.status_list=["waiting", "conform", "rac"];
$scope.list = [
{ 'name': 'A',
'status':'waiting'
},
{ 'name': 'B',
'status':'conform'
},
{ 'name': 'C',
'status':'rac'
}
]
<tr ng-repeat="person in list| filter: status">
你拼错了
具体应用 filter
over status
属性 而不是直接使用将作为包含过滤器工作的过滤器(使用压缩器设置为 true
以获得精确匹配).通过包含过滤器,您将获得列表中的人,该人的名字是您正在搜索的任何一个字符串 status
<tr ng-repeat="person in list| filter: { status: status}: true">
<td>{{person.name}}</td>
<td>{{person.status}}</td>
</tr>
Correct typo of
ng-repead
tong-repeat