So, how can I stop the infinite-scroll after a state change?
How to reproduce
- Open the Codepen.
- Open your DevTools and check the logs.
- Scroll down the user’s list and when you see the infinite-scroll’s spinner tap/click one of the users.
- Check the logs, every three seconds the function
$scope.loadMoreData
is called.
It looks like this [Resolved] Issue Beta.14: ion-infinite-scroll keep on calling the method of on-infinite
The loop starts when I navigate to other state before the ionic.infiniteScrollComplete
broadcast, in other words, when the infinite-scroll is waiting for the broadcast $scope.loadMoreData
I tried it.
$scope.$apply(function(){
$scope.$broadcast('scroll.infiniteScrollComplete');
});
I also tried to execute it with $ionicView.beforeLeave
, $ionicView.leave
events, or defining inside these events a variable to stop infinite-scroll with ng-if like
$scope.$on('$ionicView.leave', function () {
$scope.$apply(function () {
$scope.stopInfiniteScroll = true;
});
});
but it could not fix the problem.
I’m using v1.0.0-rc.1-nightly-1152
right now, I’ll make a codepen.