ng-table插件(三-分頁)

ng-table支持一個時間段內(nèi)瀏覽一段時間加載一部分數(shù)據(jù),<code>NgTableParams</code>構(gòu)造函數(shù)內(nèi)置了一個默認的分頁,并且支持設(shè)置。</br>
支持<code>getData</code>方法,需要向<code>NgTableParams</code>傳遞,多少行的數(shù)量。可以通過<code>NgTableParams.total()</code>實現(xiàn)。</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  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();//經(jīng)過設(shè)置的分頁
    function createUsingFullOptions() {
      var initialParams = {
        count: 5 // 設(shè)置每一頁展示數(shù)量
      };
      var initialSettings = {
        // page size buttons (right set of buttons in demo)
        counts: [],
        // determines the pager buttons (left set of buttons in demo)
        paginationMaxBlocks: 13,//最大頁數(shù)
        paginationMinBlocks: 2,//最小頁數(shù)
        dataset: simpleList
      };
      return new NgTableParams(initialParams, initialSettings);
    }
  }
})();
分頁.PNG
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. Java基礎(chǔ)部分 基礎(chǔ)部分的順序:基本語法,類相關(guān)的語法,內(nèi)部類的語法,繼承相關(guān)的語法,異常的語法,線程的語...
    子非魚_t_閱讀 34,728評論 18 399
  • 一. Java基礎(chǔ)部分.................................................
    wy_sure閱讀 4,012評論 0 11
  • 5-Level Paging and 5-Level EPT white paper原文 修訂版本1.1 2017...
    公子小水閱讀 4,292評論 0 3
  • 地球是一個稍微規(guī)整的圓,生活就是一個奇怪的圈。不少人活在飯肉里面,卻宣稱自己活在塵世外面。 我動了動指尖,噢,原來...
    李一十八閱讀 333評論 0 2
  • 專業(yè)組的比賽由10位義烏民間包粽子達人組成,他們經(jīng)過義烏館專業(yè)人員的層層選拔,最終在今天的舞臺上為大家展示他們包粽...
    你的喜歡很重要閱讀 255評論 0 0

友情鏈接更多精彩內(nèi)容