我已经实现了无限滚动出网站,但它是发射两次后,1次滚动。我已经使用无限滚动禁用,但它不工作的me.tell我谁怎么解决滚动问题?
$scope.loadMore = function() {
$scope.infiniteScorllStatus = true;
$scope.adv_offset ++;
if($scope.infiniteScorllStatus) {
$http.get(APP.service.userPost +
'?user_id=' + $rootScope.currentUserID + '&limit=' + $scope.limit + '&offset=' + $scope.offset + '&adv_offset=' + $scope.adv_offset).then(function(response) {
if(response.data.status == 1) {
//
$scope.shots = response.data.response;
$scope.offset = $scope.shots.length;
$scope.limit = $scope.offset + 6;
$scope.infiniteScorllStatus = false;
}
});
}
}
<div infinite-scroll="loadMore()" infinite-scroll-distance="0"
infinite-scroll-disabled="infiniteScorllStatus" >
<section class=" masonry-item" ng-repeat="item in data">
{{item.name}}
</section>
</div>我已经尝试过上面的代码,但它对我不起作用,告诉我我的代码中有什么问题?
发布于 2019-03-12 17:33:17
如果您的$scope.infiniteScorllStatus为true,则从函数返回。
$scope.loadMore = function() {
if ( $scope.infiniteScorllStatus)
return;
$scope.infiniteScorllStatus = true;
$scope.adv_offset ++;
if($scope.infiniteScorllStatus) {
$http.get(APP.service.userPost +
'?user_id=' + $rootScope.currentUserID + '&limit=' + $scope.limit + '&offset=' + $scope.offset + '&adv_offset=' + $scope.adv_offset).then(function(response) {
$scope.infiniteScorllStatus = false;
if(response.data.status == 1) {
//
$scope.shots = response.data.response;
$scope.offset = $scope.shots.length;
$scope.limit = $scope.offset + 6;
}
});
}
}https://stackoverflow.com/questions/55116478
复制相似问题