I am using the Angular-utils-pagination directive found here https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination. It is working as expected so far but the final thing I want to do, is add the ability to have the user be able to select which attribute of an item they wish to filter results on.
Below is what I have so far. The Html Markup:
<div class="row">
<div class="col-xs-4">
<h3>Current Page: {{ currentPage }}</h3>
<select ng-model="selectedFilter" ng-options="f for f in filterOptions"></select>
</div>
<div class="col-xs-4">
<label for="search">Search:</label>
<input ng-model="q" id="search" class="form-control" placeholder="Filter text">
</div>
<div class="col-xs-4">
<label for="search">items per page:</label>
<input type="number" min="1" max="100" class="form-control" ng-model="pageSize">
</div>
</div>
...
<tr dir-paginate="item in items | filter:{selectedFilter:q} | itemsPerPage: pageSize" current-page="currentPage">
The Controller
$scope.currentPage = 1;
$scope.pageSize = 10;
$scope.filterOptions = [
'item','brand','category','gender','size'
];
// Note that items[] is populated on initialisation from the db.
$scope.items = [];
When I hard code the filter to say filter by item as below, it works as expected.
<tr dir-paginate="item in items | filter:{item:q} | itemsPerPage: pageSize" current-page="currentPage">
Is it possible to make the attribute to filter on a variable? Any help is appreciated.
Thanks.