I'm using ngTable in Angularjs to implement pagination and search. The pagination works great, however search only works for the data visible on current page. How can I make a global search on the entire table irrespective of the page on which the data is displayed? One thing I know is that the pagination is applied before the search filter, and that is causing this behaviour. I'm kinda new to AngularJS, so if anyone can help me implementing a global search, it'd be great.
JS:
$scope.searchResp = function() {
$scope.pagination = new NgTableParams({
page : 1,
count : 5
}, {
counts : [],
dataset : $scope.moviejson //moviejson has got moviecode and moviename fields.
});
};
HTML:
<div class="tabpane">
Search by Movie Code: <input id="searchbar" ng-model="searchtxt.moviecode" type="text" placeholder="Enter Movie Code"><br /><br />
Search by Movie Name: <input id="searchbar" ng-model="searchtxt.moviename" type="text" placeholder="Enter Error Name"><br /><br />
<div>
<table data-ng-table="pagination" class="table table-bordered table-striped">
<thead>
<tr>
<th class="text-center" data-ng-bind="Movie Code"></th>
<th class="text-center" data-ng-bind="Movie Name"></th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="item in $data | filter : searchtxt">
<td class="center-align" data-ng-bind="item.moviecode"></td>
<td class="center-align" data-ng-bind="item.moviename"></td>
</tr>
</tbody>
</table>
</div>
</div>
It would be great if somebody can help me in implementing global search, or guide to change the order of filters so that the search filter gets fired first and pagination is done later.