ng-table插件(三-分页)

ng-table支持一个时间段内浏览一段时间加载一部分数据,NgTableParams构造函数内置了一个默认的分页,并且支持设置。

支持getData方法,需要向NgTableParams传递,多少行的数量。可以通过NgTableParams.total()实现。

Overview

ngTable supplies a pager to browse one "chunk" of data at a time.

Supply an initial paging configuration to the NgTableParams constructor call. As required, you can then change this configuration "on the fly".

Got a getData function?

Got your own getData function? Then you need to tell NgTableParams the total number of records that match its filter.

You do this by calling NgTableParams.total(). See this codepen for an example.

Default configuration

{{row.name}} {{row.age}}

Customized configuration

{{row.name}} {{row.money}}
(function() {
  "use strict";

  var app = angular.module("myApp", ["ngTable", "ngTableDemos"]);
  app.controller("demoController", demoController);
  demoController.$inject = ["NgTableParams", "ngTableSimpleMediumList"];//注入NgTableParams和ngTableSimpleMediumList
  function demoController(NgTableParams, simpleList) {
    this.defaultConfigTableParams = new NgTableParams({}, { dataset: simpleList});//默认的分页
    this.customConfigParams = createUsingFullOptions();//经过设置的分页
    function createUsingFullOptions() {
      var initialParams = {
        count: 5 // 设置每一页展示数量
      };
      var initialSettings = {
        // page size buttons (right set of buttons in demo)
        counts: [],
        // determines the pager buttons (left set of buttons in demo)
        paginationMaxBlocks: 13,//最大页数
        paginationMinBlocks: 2,//最小页数
        dataset: simpleList
      };
      return new NgTableParams(initialParams, initialSettings);
    }
  }
})();
ng-table插件(三-分页)_第1张图片
分页.PNG

你可能感兴趣的:(ng-table插件(三-分页))