如果我点击了loadnextPosts并且pageno超过了pagesize,它就不应该加载任何帖子,否则它应该警告我已经到达了最后一页。我不知道它工作的逻辑。当我点击loadnextposts时,它只是继续递增页面大小,当超过帖子数时,它会继续递增。我希望它提醒我,我已经到了帖子的末尾。
谢谢
.controller('blogController', function ($http, user, $scope, getAllTurtles, $route) {
var vm = this;
var pageno = 1;
var pagesize = 9;
getData(pageno, pagesize);
function getData(pageno, pagesize) {
$http({
url: "../Services/svBlogPost.asmx/GetAllBlogPost2",
method: "get",
params: { pn: pageno, ps: pagesize }
}).then(function (response) {
$scope.ab = response.data;
})
};
vm.loadNextPosts = function () {
pageno += 1;
getData(pageno, pagesize);
//pageno += 1;
//if (pageno >= pagesize) {
// //pageno += 1;
// getData(pageno, pagesize);
//}
//else {
// alert('reached the last page');
// //$("#loadNextPosts").prop('');
//}
}
})
function getData(pageno, pagesize) {
$http({
url: "../Services/svBlogPost.asmx/GetAllBlogPost2",
method: "get",
params: { pn: pageno, ps: pagesize }
}).then(function (response) {
$scope.ab = response.data;
})
};
$scope.btnSearch = function () {
if (vm.ddlBlogKeyword == undefined) {
//do nothing
getData(pageno, pagesize);
}
else {
$http({
url: "../Services/svBlogPost.asmx/SelectByKeyword2",
method: "get",
params: { k: vm.ddlBlogKeyword }
}).then(function (response) {
$scope.ab = response.data;
});
}
}
vm.loadNextPosts = function () {
pageno += 1;
getData(pageno, pagesize);
}
})