Charls
Charls

Reputation: 33

ngTable pager persists when searching by filter

I have a table with ng-table, when doing the search with angularjs filter I get the results, but the problem is that the pagination remains, although not in all the sections it has data, in the next example, I replicate the problem, when searching for the letter g, it appears when you click on the second pager, How could I get all the filter results without paging?

var app = angular.module('app', ["ngTable"]);
app.controller('ctrl',function($scope,NgTableParams){
  
      $scope.data = [
        {id:1,letter:"a"},
        {id:2,letter:"b"},
        {id:3,letter:"c"},
        {id:4,letter:"d"},
        {id:5,letter:"e"},
        {id:6,letter:"f"},
        {id:7,letter:"g"},
        {id:8,letter:"h"},
        {id:9,letter:"i"},
        {id:10,letter:"j"},
        {id:11,letter:"k"},
        {id:12,letter:"m"},
        {id:13,letter:"n"},
        {id:14,letter:"l"},
        {id:15,letter:"o"},
        {id:16,letter:"p"},
        {id:17,letter:"q"},
        {id:18,letter:"r"},
        {id:19,letter:"s"},
        {id:20,letter:"t"}
      ];
      
      
      $scope.tableParams = new NgTableParams({ count: 5 }, {
      dataset:  $scope.data,
      counts: [5, 10, 15, 20]
    });
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/ng-table/1.0.0/ng-table.js"></script>
   <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ng-table/1.0.0/ng-table.css">
 
 
<div ng-app="app">
  <div ng-controller="ctrl">
     <input type="search" ng-model="searchFilter" />
     <table data-ng-table="tableParams" data-show-filter="false" class="table table-bordered table-hover">
        <tr data-ng-repeat="i in $data |filter:searchFilter">
        <td data-title="'Letter'">{{i.letter}}</td>
        </tr>
     </table>
  </div>
</div>

Upvotes: 1

Views: 50

Answers (0)

Related Questions