esvit / ng-table

Simple table with sorting and filtering on AngularJS
http://esvit.github.io/ng-table
BSD 3-Clause "New" or "Revised" License
2.77k stars 851 forks source link

Custom Pagination - select #801

Open tb opened 8 years ago

tb commented 8 years ago

I need to use select for per page count. How can I edit the count with ng-model?

tb commented 8 years ago

Ok, I solved it within wrapper class:

export default angular.module('app.services.myTable', [
  'ngTable'
])
.factory('myTable', function (ngTableParams) {
  return class myTable extends ngTableParams {
    constructor(config={}) {
      super(config);
    }

    get perPage() {
      return this.count();
    }

    set perPage(count) {
      this.count(count);
    }
  }
});

This allows following code in pager.html template:

    <div ng-if="params.settings().counts.length && params.data.length > 1" class="ng-table-counts float-right">
        <select ng-options="option for option in params.settings().counts" ng-model="params.perPage"></select>
    </div>