我正在使用ons-scroller使用$ http从某些网站加载数据。但是,我传递给滚动的函数永远不会被调用。这是我的代码。
HTML
<ons-scroller infinite-scroll-enable="true" on-scrolled="loadMore()">
<ons-list>
<ons-list-item modifier="chevron" class="list-item-container" ng-repeat="post in posts">
<ons-row>
<ons-col width="95px">
<div class="thumb-wrapper">
<img src="{{post.thumbnail}}" class="thumbnail" alt="Blog image">
</div>
</ons-col>
<ons-col>
<div class="name">
{{post.title}}
</div>
<div class="location">
{{post.description}}
</div>
</ons-col>
</ons-row>
</ons-list-item>
</ons-list>
</ons-scroller>
AngularJS
var offset = 0;
$scope.posts = [];
$scope.loadMore = function(){
if(offset == 0){
$http({
method: "GET",
url: domain + "blog/list",
})
.success(function(data){
$scope.posts = data.response.posts;
offset++;
$scope.loadMore();
});
}else{
$http({
method: "GET",
url: domain + "blog/list",
params: {
offset: offset,
}
})
.success(function(data){
for(i = 0; i < data.response.posts.length; i++){
$scope.posts.push(data.response.posts[i]);
}
offset++;
if(data.response.posts.length == 0){
return;
}
$scope.loadMore();
});
}
}
$scope.loadMore();
我正在调用loadMore();在我的控制器中手动操作。