-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
22 lines (21 loc) · 797 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var app = angular.module('app', ['ngTable']);
app.controller('MainCtrl', ['$scope', '$http','ngTableParams' ,
function ($scope, $http, ngTableParams) {
var tableData = []
//Table configuration
$scope.tableParams = new ngTableParams({
page: 1,
count: 6,
sorting: { userId: "desc" }
},{
total:tableData.length,
//Returns the data for rendering
getData : function($defer,params){
$http.get('https://jsonplaceholder.typicode.com/posts').then(function(response) {
tableData = response.data;
$defer.resolve(tableData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
params.total(tableData.length);
});
}
});
}]);