0

我在 Angular js 中使用 ngInfiniteScroll 我的 js 函数是

$scope.busy = false;
    $scope.nextPage = function() {
         if ($scope.busy) return;
        var checkLast = $("#endlistings").val();
        var off_set = $("#offSet").val();
        var offsetCounter = parseInt($("#offSetCounter").val()) - parseInt(10);
        newrec = parseInt(off_set) + 10;
        if (off_set >= 10 ){
            $scope.busy = true;
            console.log("if");
            var url = CONFIG.APIURL + "Deployed_pets/getDeployedPetsResults/" + off_set + "/" + offsetCounter;
            $http.get(url).success(function(data) {
               angular.extend($scope.deployed_pets, data.deployed_pets);
               $("#offSet").val(newrec);
              $scope.busy = false;
            });
        }
    };

我的html文件是

<div class="row" infinite-scroll='nextPage()' infinite-scroll-disabled='busy' infinite-scroll-distance='1'>
    <div class="col-sm-6"  ng-repeat="deployedpet in deployed_pets">
        {{data}}
    </div>
    <div ng-show='busy'>Loading data...</div>
</div>

在我第一次向下滚动后它可以正常工作但在我第一次向下滚动后它继续加载数据

4

0 回答 0