我有3张桌子。每个人代表具有不同角色的用户。这些适用于管理员,基本用户和所有用户。我想在我的ng-repeat
或我的控制器中添加一个过滤器,以便仅显示具有与我想要的角色匹配的角色的用户。这是我的目标:
{
"object": {
"users": [
{
"uuid": "19c5808b-0dcf-4b62-9c09-6caac1a5",
"fullname": "Brittani V",
"email": "brit@test.com",
"role": "root",
"last_log_in": 1427806300,
"deleted_at": null,
"active": true
},
{
"uuid": "b88415e9-a492-4206-83b4-5e7c42df",
"fullname": "Eric S.",
"email": "eric@test.com",
"role": "root",
"last_log_in": 1427817626,
"deleted_at": null,
"active": true
},
{
"uuid": "25649ad3-0e72-4946-b5bf-3484dcd2",
"fullname": "Joshua H.",
"email": "josh@test.com",
"role": "root",
"last_log_in": 1427813063,
"deleted_at": null,
"active": true
}
]
这是我的表格,其类别名称为'管理员'
<tab heading="Administrators">
<table class="table table-hover members-table middle-align">
<thead>
<tr>
<!-- <th></th> -->
<th>Name and Role</th>
<th class="hidden-xs hidden-sm">E-MAIL</th>
<th>Last Login<th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users **if user's role == root** ">
<!-- <td class="user-cb">
<input type="checkbox" class="cbr" name="members-list[]" value="1" checked />
</td>-->
<td class="user-name">
<a href="" class="name">{{user.fullname}}</a>
<span>{{user.role}}</span>
</td>
<td class="hidden-xs hidden-sm">
<span class="email">{{user.email}}</span>
</td>
<td class="user-id">
{{user.last_log_in}}
</td>
<td class="text-right">
<a href="" class="edit">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</td>
<td class="text-right">
<a href="" class="delete">
<span class="glyphicon glyphicon-remove"></span>
</a>
</td>
</tr>
</tbody>
</table>
</tab>
答案 0 :(得分:0)
使用ng-if
或ng-hide
<tr ng-repeat="user in users" ng-if="user.role == 'root'">