Display the list of users based on the selected status using the following JSP code:
<table>
<thead>
<tr>
<th>Aggregate</th>
<th>User id</th>
<th>First Name</th>
<th>Last Name</th>
<th>Phone Number</th>
<th>Email</th>
<th class="text-center">Status</th>
</tr>
</thead>
<tbody >
<tr>
<td><input type="text" class="form-control" ng-model="search.agId" /></td>
<td><input type="text" class="form-control" ng-model="search.id" /></td>
<td><input type="text" class="form-control" ng-model="search.firstName" /></td>
<td><input type="text" class="form-control" ng-model="search.lastName" /></td>
<td><input type="text" class="form-control" ng-model="search.mobileNo" /></td>
<td><input type="text" class="form-control" ng-model="search.emailId" /></td>
<td>
<select class="form-control" ng-model="search.status">
<option value=""> Select </option>
<option value="ACTIVE"> Active </option>
<option value="INACTIVE"> In Active </option>
<option value="B"> Blocked </option>
</select>
</td>
</tr>
<tr ng-repeat="userone in filtereddata = (users.data | filter:search)">
<td>{{ userone.agId }}</td>
<td>{{ userone.id }}</td>
<td>{{ userone.firstName }}</td>
<td>{{ userone.lastName }}</td>
<td>{{ userone.mobileNo }}</td>
<td>{{ userone.emailId }}</td>
<td class="text-center" ng-switch on="userone.status">
<span class="inac label label-success" ng-switch-when="ACTIVE">Active</span>
<span class="inac label label-danger" ng-switch-when="INACTIVE">In Active</span>
<span class="inac label label-danger" ng-switch-when="B">Blocked</span>
</td>
</tr>
</tbody>
</table>
Controller JS code
$scope.$watch('search', function (newVal, oldVal) {
$scope.filtered = filterFilter($scope.users.data, newVal);
console.log($scope.filtered);
$scope.bigTotalItems = (typeof $scope.filtered == 'undefined' ) ? 0 : $scope.filtered.length;
$scope.noOfPages = Math.ceil($scope.bigTotalItems/$scope.entryLimit);
$scope.currentPage = 1;
}, true);
The code works for INACTIVE and blocked users (i.e. B), however, it shows all users with ACTIVE and INACTIVE statuses when Active is selected.
In the Controller JS code, there is a simple console.log($scope.filtered)
that returns both ACTIVE and INACTIVE members in the filtered data when Active is chosen. It works fine for other selections.
If more information is required, feel free to ask