我要做一个滚到底部自动加载更多的功能,现在用了插件ng-infinite-scroll,写成这样:
JS:
egVideoApp.controller('videoListCtrl',
function ($scope, addMore) {
$scope.addmore = new addMore();
});
egVideoApp.factory('addMore', function ($http) {
var addMore = function () {
this.videos = [];
this.busy = false;
this.after = '';
this.page = 1;
};
addMore.prototype.nextPage = function () {
if (this.busy) return;
this.busy = true;
var url = "http://api.ergeng.com/normalvideo/list?after=" + this.after + "&callback=JSON_CALLBACK";
$http.jsonp(url).success(function (data) {
console.log(data);
var videos = data.data.list;
for (var i = 0; i < videos.length; i++) {
this.videos.push(videos[i]);
}
this.after =this.videos[this.videos.length - 1].id;
this.busy = false;
this.page += 1;
}.bind(this));
};
return addMore;
});
html:
{{video.title}}
{{video.category_name}}
{{video.duration}}


现在后台给我两个接口,一个page,一个pageSize,如何和现有的代码结合起来?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
走同样的路,发现不同的人生