Browse Source

pagination added to travels feed

master
arnaucode 7 years ago
parent
commit
237dec4dfc
3 changed files with 15 additions and 5 deletions
  1. +2
    -2
      www/js/app.js
  2. +10
    -3
      www/js/travels.js
  3. +3
    -0
      www/templates/travels.html

+ 2
- 2
www/js/app.js

@ -6,9 +6,9 @@
// 'starter.controllers' is found in controllers.js // 'starter.controllers' is found in controllers.js
//var urlapi = "http://localhost:3000/api/";
var urlapi = "http://localhost:3000/api/";
//var urlapi="https://collectivecar.paas.primustech.io/api/"; //var urlapi="https://collectivecar.paas.primustech.io/api/";
var urlapi="http://147.83.7.158:3000/api/";
//var urlapi="http://147.83.7.158:3000/api/";
angular.module('starter', [ angular.module('starter', [

+ 10
- 3
www/js/travels.js

@ -4,14 +4,15 @@ angular.module('app.travels', ['pascalprecht.translate'])
$scope.travels=[]; $scope.travels=[];
$scope.page=0;
$scope.doRefresh = function() { $scope.doRefresh = function() {
/* travels refresh: */ /* travels refresh: */
$http.get(urlapi + 'travels')
$http.get(urlapi + 'travels?page=' + $scope.page)
.then(function(data){ .then(function(data){
console.log('data success travels'); console.log('data success travels');
console.log(data); // for browser console console.log(data); // for browser console
$scope.travels = data.data; // for UI
//$scope.travels = data.data; // for UI
$scope.travels=$scope.travels.concat(data.data);
$scope.$broadcast('scroll.refreshComplete');//refresher stop $scope.$broadcast('scroll.refreshComplete');//refresher stop
}, function(data){ }, function(data){
@ -22,4 +23,10 @@ angular.module('app.travels', ['pascalprecht.translate'])
}); });
}; };
$scope.doRefresh(); $scope.doRefresh();
$scope.paginationNext = function(){
$scope.page++;
console.log($scope.page);
$scope.doRefresh();
};
}); });

+ 3
- 0
www/templates/travels.html

@ -34,5 +34,8 @@
</p> </p>
</a> </a>
</div> </div>
<div class="button" ng-click="paginationNext()">
load more
</div>
</ion-content> </ion-content>
</ion-view> </ion-view>

Loading…
Cancel
Save