AngularJS ng-table外掛程式設定排序_AngularJS

來源:互聯網
上載者:User

基礎概念

ng-table提供了一個表頭來提供,基礎的過濾資訊:

(1)指定一列的過濾器,然後模板就會使用。
(2)ngTable支援number, text, select 和 select-multiple的值模板。
(3)可以有選擇的為NgTableParams提供初始過濾值。

 <div class="row"> <div class="col-md-6" ng-controller="demoController as demo">  <h3>ngTable directive</h3>  <table ng-table="demo.tableParams" class="table table-condensed table-bordered table-striped">  <tr ng-repeat="row in $data">   <td data-title="'Name'" filter="{name: 'text'}">{{row.name}}</td>   <td data-title="'Age'" filter="{age: 'number'}">{{row.age}}</td>   <td data-title="'Money'">{{row.money}}</td>   <td data-title="'Country'" filter="{ country: 'select'}" filter-data="demo.countries">{{row.country}}</td>  </tr>  </table> </div> <div class="col-md-6" ng-controller="dynamicDemoController as demo">  <h3>ngTableDynamic directive</h3>  <table ng-table-dynamic="demo.tableParams with demo.cols" class="table table-condensed table-bordered table-striped">  <tr ng-repeat="row in $data">   <td ng-repeat="col in $columns">{{row[col.field]}}</td>  </tr>  </table> </div> </div>
(function() { "use strict"; var app = angular.module("myApp", ["ngTable", "ngTableDemos"]); app.controller("demoController", demoController); demoController.$inject = ["NgTableParams", "ngTableSimpleMediumList", "ngTableDemoCountries"]; //注入NgTableParams(ngtablemodule)和ngTableSimpleMediumList、ngTableDemoCountries兩個資料來源 function demoController(NgTableParams, simpleList, countries) { this.countries = countries;//初始化selcet的資料來源 this.tableParams = new NgTableParams({  // initial filter  filter: { name: "T" } //初始過濾條件 }, {  dataset: simpleList }); } app.controller("dynamicDemoController", dynamicDemoController); dynamicDemoController.$inject = ["NgTableParams", "ngTableSimpleMediumList", "ngTableDemoCountries"]; function dynamicDemoController(NgTableParams, simpleList, countries) { this.cols = [//自訂table條目,過濾條件、表頭名字和資料來源,filterData: countries。  { field: "name", title: "Name", filter: { name: "text" }, show: true },  { field: "age", title: "Age", filter: { age: "number" }, show: true },  { field: "money", title: "Money", show: true },  { field: "country", title: "Country", filter: { country: "select" }, filterData: countries, show: true } ]; this.tableParams = new NgTableParams({  // initial filter  filter: { country: "Ecuador" } //初始化資料來源 }, {  dataset: simpleList }); }})();(function() { "use strict"; angular.module("myApp").run(setRunPhaseDefaults); setRunPhaseDefaults.$inject = ["ngTableDefaults"];//通過config來設定表格數量 function setRunPhaseDefaults(ngTableDefaults) { ngTableDefaults.params.count = 5; ngTableDefaults.settings.counts = []; }})();

以上就是對AngularJS ng-table外掛程式 的資料整理,後續繼續補充相關資料,謝謝大家對本站的支援!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.