From 8094fc839c6e377e1c335fd58f35bded4312bdc5 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sat, 9 Aug 2014 18:42:54 +0200 Subject: [PATCH] ng-table parameters --- public/app/js/main/controllers/BalanceCtrl.js | 13 +++++++++++-- public/app/js/main/templates/balance.tpl.html | 12 ++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/public/app/js/main/controllers/BalanceCtrl.js b/public/app/js/main/controllers/BalanceCtrl.js index 07c66aef..6df48651 100644 --- a/public/app/js/main/controllers/BalanceCtrl.js +++ b/public/app/js/main/controllers/BalanceCtrl.js @@ -1,6 +1,6 @@ app.controller( 'BalanceCtrl', - [ '$scope', '$http', '$filter', - function( $scope, $http, $filter ) { + [ '$scope', '$http', '$filter', 'ngTableParams', + function( $scope, $http, $filter, ngTableParams ) { $scope.now = moment(); $scope.previous_period = function() { $scope.now.subtract( 'months', 1 ); @@ -62,6 +62,15 @@ app.controller( 'BalanceCtrl', }; }; + $scope.tableParams = new ngTableParams( { page: 1, // show first page + count: 999 // count per page + }, + { counts: [], // hide page counts control + total: 1, // value less than count hide pagination + getData: function($defer, params) { + $defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count())); + } } ); + var retrieve_data = function() { $scope.balance = { expenses: [], income: [], diff --git a/public/app/js/main/templates/balance.tpl.html b/public/app/js/main/templates/balance.tpl.html index 3d618f24..7132a3aa 100644 --- a/public/app/js/main/templates/balance.tpl.html +++ b/public/app/js/main/templates/balance.tpl.html @@ -39,10 +39,10 @@ @@ -71,10 +71,10 @@