I have 3 tables. Each one represents users with different roles. These are for Admins, basic users and ALL users. I want to add a filter onto my ng-repeat
, or in my controller, to show only users with a role that matches what I want. Here is my object:
{
"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
}
]
Here's my table with the category name of 'Administrator'
<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>
Use ng-if
, or ng-hide
<tr ng-repeat="user in users" ng-if="user.role == 'root'">