我正在使用 NIS 进行无休止的滚动,我实现了它,它工作正常,除了一个问题。就像我float: left
用来维护 div 标签一样。但是在使用float
它之后一次发送多个请求,但是当我删除float:left
它时,它会发送我想要的单个请求。
我一次从服务器获得 20 个结果
我没有在 JsFiddle 或 Plunker 上提供示例的公共 URL。
这是我的代码
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script src="js/angular/lib/angular.min.js"></script>
<script src="js/angular/lib/ng-infinite-scroll.min.js"></script>
<script src="js/angular/customjs/endless_scroll.js"></script>
<style type="text/css">
.test{
float:left;
}
</style>
</head>
<body ng-app="myApp">
<div ng-controller='DemoController'>
<div id="scroll" infinite-scroll='reddit.nextPage();'
infinite-scroll-container="'scroll'"
infinite-scroll-disabled='reddit.stopscript'
infinite-scroll-distance='2'>
<div ng-repeat='item in reddit.items'>
<div class="test">
<div style="height:30px;width:200px; border-style:solid;border-width:medium;">{{item.bookmark_id}}</div>
<div style="height:100px;width:200px; border-style:solid;border-width:medium;">{{item.bookmark_title}}</div>
</div>
</div>
</div>
<div ng-show='reddit.busy'>Loading data...</div>
</div>
</body>
</html>
这是我的控制器
var myApp = angular.module('myApp', ['infinite-scroll']);
myApp.controller('DemoController', function ($scope, Reddit) {
$scope.reddit = new Reddit();
});
myApp.factory('Reddit', function ($http) {
var Reddit = function () {
this.items = [];
this.busy = false;
this.stopscript = false;
};
Reddit.prototype.nextPage = function () {
if (this.busy){
return;
}
else{
this.busy = true;
var url = "http://example.com/get_recent_articles/";
$http.get(url).success(function (data) {
if (data.recently_added.bookmarks.length == 0) {
this.stopscript = true;
}
else {
this.items.push.apply(this.items, data.recently_added.bookmarks);
}
this.busy = false;
}.bind(this));
}
};
return Reddit;
});
有人可以帮我解决这个问题吗?
谢谢你。