【发布时间】:2017-09-04 18:28:09
【问题描述】:
我想在ng-repeat 中过滤一些值,我已经尝试过但没有解决方案...
我正在寻找三种解决方案,
(i) 首先在我的 plunker 中,我希望过滤列表中 parent 的 ng-module="request_role" 值。所以我试过| filter: request_role.[parent']。
(ii) 在我的 plunker 第二个列表中,我希望过滤 ng-module="request_role" 的 Change Agent 值。所以我试过| filter: request_role.['Change Agentent']。
(i) 在我的 plunker 第三个列表中,我希望过滤 ng-module="request_role" 的 parent,Change Agent 值。所以我试过| filter: request_role.['parent,Change Agent']。
- 我认为我在
filter中犯了一个错误,所以请检查并更新我的 plunker 以了解确切的解决方案,谢谢...
我的 HTML:-
<p style="background: black;color:white">1.Filter request_role value of `parent` data's in below list</p>
<div ng-repeat="question in users | filter: request_role.['parent']">
<small>
<table border="0">
<tbody>
<th>{{question.displayName}}</th>
<th style="background: yellow;">,{{question.roles[0]}}</th>
<th style="background: light;">,{{question.request_role[0]}}</th>
</tbody>
</table>
</small>
</div>
<p style="background: black;color:white">2. Filter request_role value of `Change Agent ` data's in below list</p>
<div ng-repeat="question in users | filter: request_role.['Change Agent']">
<small>
<table border="0">
<tbody>
<th>{{question.displayName}}</th>
<th style="background: yellow;">,{{question.roles[0]}}</th>
<th style="background: light;">,{{question.request_role[0]}}</th>
</tbody>
</table>
</small>
</div>
<p style="background: black;color:white">3.Filter request_role Both value of ["parent","Change Agent"] data's in below list</p>
<div ng-repeat="question in users | filter: request_role.['parent,Change Agent']">
<small>
<table border="0">
<tbody>
<th>{{question.displayName}}</th>
<th style="background: yellow;">,{{question.roles[0]}}</th>
<th style="background: light;">,{{question.request_role[0]}}</th>
</tbody>
</table>
</small>
</div>
我的过滤器:-
1. | filter: request_role.['parent']
2. | filter: request_role.['Change Agent']
3. | filter: request_role.['parent,Change Agent']
【问题讨论】: