我正在尝试使用 ngInfiniteScroll。但它不起作用。谁能解释我做错了什么
post.html - 应该触发滚动的帖子列表
<div infinite-scroll="getMoreData()">
<article ng-repeat="post in posts" class="postContainer">
<img src="{{post.media.m}}" />
<h2><a href="#/post/{{ posts.indexOf(post) }}">{{ post.title }}</a></h2>
</article>
</div>
控制器.js
angular.module('app.controllers', [
'app.directives'])
.controller('PostController', ['$scope', '$http', function($scope, $http){
$http.jsonp('https://api.flickr.com/services/feeds/photos_public.gne?tags=flower&tagmode=all&format=json').success(function(data){
});
jsonFlickrFeed = function(data){
$scope.posts = data.items.slice(0, 5);
}
$scope.getMoreData = function () {
console.log("scroll");
$scope.posts = $scope.posts.slice(0, $scope.posts.length + 5);
}
}])
触发了滚动,但没有数据添加到页面
更新
当我改变这个时问题解决了
jsonFlickrFeed = function(data){
$scope.posts = data.items.slice(0, 5);
$scope.getMoreData = function () {
$scope.posts = data.items.slice(0, $scope.posts.length + 5);
}
}