Problem with ion-scroll-infinite


#1

I’m trying to update my list every time the user scroll down the list. The problem is that it works once, I followed several examples of this and each had its generic data. What I try to do is go to see a WebService for less than an ID list that sent me, it is why we need to always keep a id as the last. All this works very well, but then I can not continue to update even so, updating the last ID, the scroll is hidden.

$scope.loadMore = function() {
  console.log('Loading more!');
  $timeout(function() {
    $scope.refresh_view = [];
  console.log(UrlService.url+'refreshView/'+sessionService.get("user_id")+'/'+sessionService.get("hash")+"/"+$scope.ultima_id);
  $http({method: 'GET', url: UrlService.url+'refreshView/'+sessionService.get("user_id")+'/'+sessionService.get("hash")+"/"+$scope.ultima_id})
    .success(function(data){
      if(data.Count > 0){
        angular.forEach(data.View, function(value, key) {
          if(data.Count-1 == key){
            $scope.ultima_id = value.id;
          }
          $scope.refresh_view.push(value);
        });
        $scope.views = $scope.views.concat($scope.refresh_view);

        console.log($scope.ultima_id);
      }else{
        $scope.moredata=true;
      }
    });

    $scope.$broadcast('scroll.infiniteScrollComplete');
          $scope.$broadcast('scroll.resize');
    $scope.$broadcast('scroll.resize')
  }, 1000);
}

JS:

$scope.$on('$ionicView.enter', function(){
  $scope.ultima_id = 0;
  function success(pos) {
    $scope.latitud = pos.coords.latitude
    $scope.longitud =  pos.coords.longitude;
  };

  function error(err) {
    
  };

  navigator.geolocation.getCurrentPosition(success,error);
  $scope.getViews();
});
.controller('MisViewsCtrl', function($scope,$ionicNavBarDelegate,$timeout,$location,$ionicPlatform,$ionicLoading, $compile,$ionicPopup,sessionService,$http,$cordovaSQLite, UrlService){
   $scope.moredata = false;

HTML :

<ion-infinite-scroll on-infinite="loadMore()" ng-if="!moredata" distance="2"></ion-infinite-scroll>