【发布时间】:2014-05-28 22:19:03
【问题描述】:
我在 ng-repeat 上进行无限滚动,使用 loadMore() 函数更改 limitTo 值。
代码如下:
指令(在 jsfiddle 上找到):
angular.module('scroll', []).directive('whenScrolled', function() {
return function(scope, elm, attr) {
var raw = elm[0];
elm.bind('scroll', function() {
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
scope.$apply(attr.whenScrolled);
}
});
};
});
这是进入控制器的代码:
var nb = 15;
$rootScope.vue = nb;
$rootScope.loadMore = function() {
$rootScope.vue = $rootScope.vue + 5;
}
这里是 html 中的代码:
<div class="container-fluid" id="full-2">
<div class="row" id="full-3">
<div class="col-xs-12 col-md-10" id="fixed" when-scrolled="loadMore()">
<ul>
<li ng-repeat="pg in eleves0 | search:query:['millesime']:operator | orderBy:orderProp | limitTo:vue">
[...]
</li>
</ul>
</div>
</div>
这里是css:
html, body{
background-color:#ccc;
height:100%;
}
#full{
height:100%;
}
#full-1{
height:90%;
}
#full-2{
height:100%;
}
#full-3{
height:100%;
}
#fixed{
height:100%;
overflow: auto;
}
此代码在 IE、Firefox、Opera 上完美运行。当我向下滚动时,会出现新内容
它不适用于全屏 Chrome。 如果窗口的高度
你知道它可能来自哪里吗?如何解决?
【问题讨论】:
-
你还有问题吗?
标签: javascript css angularjs scroll