我在用 Laravel 实现 angularJs 的ngInfiniteScroll库时遇到了问题,事实是我在我的 Angular 服务中没有遇到这个错误
function PostServices($http, $q, CONFIG) {
return {
getPots: getPots,
// postCheck: postCheck,
postSave: postSave
};
this.recipes = [];
this.loading = false;
this.page = 1;
function getPots() {
var url = CONFIG.APIURL + 'post/ajaxviewpublish?page=' + this.page;
if (this.loading) return;
this.loading = true;
$http.get(url)
.success(function (data) {
console.log(data.message.data);
for (var i = 0; i < data.message.data.length; i++) {
this.recipes.push(data.message.data[i]);
}
this.page++;
this.loading = false;
recipes.loading = true; // This should prevent more code from being loaded.
}.bind(this));
}
return getPots;
也许'this'引用了错误的对象,请尝试以下操作:
也许你必须为
page
y做同样的事情loading