sroze / ngInfiniteScroll

Infinite Scrolling for AngularJS
http://sroze.github.com/ngInfiniteScroll/
MIT License
2.89k stars 723 forks source link

ngInfiniteScroll is firing two times in the call stack for single initialisation #374

Open swatjoshi opened 6 years ago

swatjoshi commented 6 years ago

Hi I am trying to achieve infinite scrolling for dynamic data coming from server, but sometimes I am getting two responses even-though client is firing single request. On debugging I see nginfinite-scroll.min.dir.js is getting called twice in call stack so I am receiving two responses. Can you please help me in fixing this problem? Thank you

brazorf commented 6 years ago

I've a similar issue. This is my controller

function loadNodes(ipp, page) {
    return api.data().sort('created_at', 'desc').paginate('node', ipp, page);
}

$scope.nodes = [];

var page = 0, ipp = 15;

$scope.loadMore = function() {
    loadNodes(ipp, ++page).then(function(response){
        $scope.nodes = $scope.nodes.concat(response.data);
    });
}

and this is pretty much my view

<div class="card-columns"
     infinite-scroll="loadMore()"
     infinite-scroll-use-document-bottom="true">
    <node-card node="n" ng-repeat="n in nodes"></node-card>
</div>

I kind of fixed this by adding a "load in progress flag" and adding this option infinite-scroll-disabled="loading", but the issue itself remains.