You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. angular.module('app.travels', ['pascalprecht.translate'])
  2. .controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
  3. $scope.loadMorePagination = true;
  4. $scope.travels = [];
  5. $scope.page = 0;
  6. $scope.doRefresh = function() {
  7. /* travels refresh: */
  8. $http.get(urlapi + 'travels?page=' + $scope.page)
  9. .then(function(data) {
  10. console.log('data success travels');
  11. console.log(data); // for browser console
  12. //$scope.travels = data.data; // for UI
  13. $scope.travels = $scope.travels.concat(data.data);
  14. $scope.$broadcast('scroll.refreshComplete'); //refresher stop
  15. $scope.$broadcast('scroll.infiniteScrollComplete');
  16. if (data.data.length < 1) {
  17. console.log("setting loadMorePagination to false");
  18. $scope.loadMorePagination = false;
  19. $scope.$broadcast('scroll.infiniteScrollComplete');
  20. }
  21. }, function(data) {
  22. console.log('data error');
  23. $scope.$broadcast('scroll.refreshComplete'); //refresher stop
  24. $ionicLoading.show({
  25. template: 'Error connecting server',
  26. noBackdrop: true,
  27. duration: 2000
  28. });
  29. });
  30. };
  31. $scope.doRefresh();
  32. $scope.paginationNext = function() {
  33. if ($scope.loadMorePagination == true) {
  34. $scope.page++;
  35. console.log($scope.page);
  36. $scope.doRefresh();
  37. }else{
  38. console.log("limit pagination reached");
  39. $scope.$broadcast('scroll.infiniteScrollComplete');
  40. }
  41. };
  42. });