The Angularjs table in the project is ng-table and powerful, such as searching, sorting, checkbox, paging, number of table displays per page, and so on. Api,demo Anything can only refer to the official website. Here is a memo, which day will definitely be used.
Html:
JS:
var app = Angular.module (' main ', [' ngtable ']).
Controller (' Democtrl ', function ($scope, ngtableparams, Nameservice) {var data = Nameservice.data;
$scope. Tableparams = new Ngtableparams ({page:1,//Show the page count:10,//Count per page Sorting: {name: ' ASC '}}, {total:0,//Length of data getdata:function ($defer, params) {Nameservic
E.getdata ($defer, params, $scope. Filter);
}
});
$scope. $watch ("filter.$", function () {$scope. Tableparams.reload ();
});
}); App.service ("Nameservice", Function ($http, $filter) {function Filterdata (data, filter) {return $filter (' filter ') (data
, filter); function OrderData (data, params) {return params.sorting () $filter (' by ') (data, Params.orderby ()): Filteredda
Ta function Slicedata (data, params) {return Data.slice (Params.page ()-1) * Params.count (), Params.page () * params.co UNT ())} function Transformdata (data,filter,params) {return Slicedata ( OrderData (Filterdata (Data,filter), params), params);
The var service = {cacheddata:[], getdata:function ($defer, params, filter) {if (service.cacheddata.length>0) {
Console.log ("Using cached Data") var Filtereddata = Filterdata (Service.cacheddata,filter);
var transformeddata = Slicedata (OrderData (filtereddata,params), params);
Params.total (filtereddata.length) $defer. Resolve (Transformeddata); else{Console.log ("fetching Data") $http. Get ("Data.json"). Success (function (RESP) {angular.copy (resp
, Service.cacheddata) params.total (resp.length) var filtereddata = $filter (' filter ') (resp, filter);
var transformeddata = Transformdata (resp,filter,params) $defer. Resolve (Transformeddata);
});
}
}
};
return service;
});
JSON data:
[{
"hidden": 1,
"launchimage": "2015_4_9_12_bb7e0a446ed74ae7ad0a3554a54183bc_1298477763",
"name": "John ",
" OrgID ": 1498031949070997504,
" OrganizationId ":" 1498031949070997504 "
}, {
" hidden ": 1,
" Launchimage ":" http://7s1rmc.com1.z0.glb.clouddn.com/2015_4_9_12_0ab5b02cf1df4ac49a7376b820816307_2127491219| 39e202124ac90ec531009b0edbbbe0ba ",
" name ":" Dick ",
" OrgID ": 1498046360909250560,"
OrganizationId ":" 1498046360909250560 "
}]
The above is the entire content of this article, I hope to help you learn.