When infinite scroll is executed


#1

hi everybody,
i m trying to implement loadMore() function on infinite-scroll , the issue is that load more is executed automatically wihtout scrolling down and the other problem is that the function doesn’t work any more when i charge a new slide my view is like that :

my controller is like bellow:

.controller('ActivityController',function($scope, $http,$state,$ionicSlideBoxDelegate,$timeout,$rootScope,globalVariables,$stateParams) {
  
    $http.get('http://192.168.1.180:8080/backendPay/v1/Account/inquiryAll/'+$rootScope.member.idUser+'?access_token='+$rootScope.clientToken).success(function(data){

    $rootScope.listOfAccounts=data.accounts;
    $ionicSlideBoxDelegate.update();
    $rootScope.AccountFirstIndex=data.accounts[0].idAccount;
        $http({    
method:"POST",
url:'http://192.168.1.180:8080/backendPay/v1/Payment/inquiryAllPage/'+$rootScope.AccountFirstIndex+'?access_token='+$rootScope.clientToken,
data:{"count":1,"startId":globalVariables.pagingSize ,"sortBy":"createTime","sortOrder":"desc"}
        
    }).success(function(data){
      //listPay
            $scope.listAccount=data.list_payment_pageable;
            $ionicSlideBoxDelegate.update();
        
});
    });
    

    
    $scope.slideHasChanged=function(index){
        $rootScope.deosSlideChanged=false;
        $rootScope.AccountFirstIndexe=index; 
        globalVariables.pagingSize=0;
        $scope.listAccount=new Array();
        
        $http({    
                method:"POST",
                url:'http://192.168.1.180:8080/backendPay/v1/Payment/inquiryAllPage/'+$rootScope.AccountFirstIndexe+'?access_token='+$rootScope.clientToken,
                data:{"count":1,"startId":globalVariables.pagingSize,"sortBy":"createTime","sortOrder":"desc"}
            
        }).success(function(data){
                $scope.listAccount=data.list_payment_pageable;
                $scope.$on('$stateChangeSuccess', function() { 
    $scope.loadMore();
  }); 
                console.log($scope.listAccount);
                });


        
    };
     $scope.loadMore=function(){
    
     globalVariables.pagingSize=$scope.listAccount.length;
     console.log("loadMore");
     $http({    
         method:"POST",
         url:'http://192.168.1.180:8080/backendPay/v1/Payment/inquiryAllPage/'+$rootScope.AccountFirstIndex+'?access_token='+$rootScope.clientToken,
         data:{"startId":globalVariables.pagingSize,"count":1,"sortBy":"createTime","sortOrder":"desc"}
    }).success(function(data){
      
        if(angular.equals([],data.list_payment_pageable)){
                $rootScope.noMoreItemsAvailable=true;   
        }
         else{
             console.log(data.list_payment_pageable);
            $scope.listAccount.push(data.list_payment_pageable[0]); 
          }
     });
     $scope.$broadcast('scroll.infiniteScrollComplete');
    };
    	     
})

thank you


#2

the first loadMore is called because your scroll-content of the page has no height --> so you are automatically in the “loadMore”-Zone and the loadMore function gets called.

sorry but the code is to ugly to read^^.

Maybe you might build a codepen with your problem.
It is much easier to work with.


#3

thank you @bengtler and i 'm sorry for tha quality of the way i’ve posted the controller, i just want to know how could i call load more manually


#4

Your loadMore function is defined on the $scope of the controller… so you can call loadMore simply by writing $scope.loadMore(); like you did here:


#5

thank you a lot @bengtler