ng-table插件(三-分页)

ng-table支持一个时间段内浏览一段时间加载一部分数据,<code>NgTableParams</code>构造函数内置了一个默认的分页,并且支持设置。</br>
支持<code>getData</code>方法,需要向<code>NgTableParams</code>传递,多少行的数量。可以通过<code>NgTableParams.total()</code>实现。</br>

<div ng-app="myApp" class="container-fluid" ng-controller="demoController as demo">
  <div class="row">
    <div class="col-xs-12">
      <h2 class="page-header">Pagination - basic example</h2>
      <div class="row">
        <div class="col-md-6">
          <div class="bs-callout bs-callout-info">
            <h4>Overview</h4>
            <p><code>ngTable</code> supplies a pager to browse one "chunk" of data at a time. </p>
            <p>Supply an initial paging configuration to the <code>NgTableParams</code> constructor call. As required, you can then change this configuration "on the fly".</p>
          </div>
        </div>
        <div class="col-md-6">
          <div class="bs-callout bs-callout-warning">
            <h4>Got a <code>getData</code> function?</h4>
            <p>Got your own <code>getData</code> function? Then you need to tell <code>NgTableParams</code> the total number of records that match its <code>filter</code>.</p>
            <p>You do this by calling <code>NgTableParams.total()</code>. See <a href="http://codepen.io/christianacca/pen/mJoGPE" target="_">this codepen</a> for an example.</p>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-6">
      <h3>Default configuration</h3>
      <table ng-table="demo.defaultConfigTableParams" class="table table-condensed table-bordered table-striped">
        <tr ng-repeat="row in $data">
          <td data-title="'Name'">{{row.name}}</td>
          <td data-title="'Age'">{{row.age}}</td>
        </tr>
      </table>
    </div>
    <div class="col-md-6">
      <h3>Customized configuration</h3>
      <table ng-table="demo.customConfigParams" class="table table-condensed table-bordered table-striped">
        <tr ng-repeat="row in $data">
          <td data-title="'Name'">{{row.name}}</td>
          <td data-title="'Money'">{{row.money}}</td>
        </tr>
      </table>
    </div>
  </div>
</div>
(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);
    }
  }
})();
分页.PNG
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,779评论 18 399
  • 一. Java基础部分.................................................
    wy_sure阅读 3,839评论 0 11
  • 5-Level Paging and 5-Level EPT white paper原文 修订版本1.1 2017...
    公子小水阅读 3,993评论 0 3
  • 地球是一个稍微规整的圆,生活就是一个奇怪的圈。不少人活在饭肉里面,却宣称自己活在尘世外面。 我动了动指尖,噢,原来...
    李一十八阅读 309评论 0 2
  • 专业组的比赛由10位义乌民间包粽子达人组成,他们经过义乌馆专业人员的层层选拔,最终在今天的舞台上为大家展示他们包粽...
    你的喜欢很重要阅读 232评论 0 0