Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tutorial App part 4 - ArticlesCtrl
.controller('ArticlesCtrl', ['$scope', 'Articles', function($scope, Articles) {
$scope.page = 0;
$scope.articles = [];
$scope.morePageExist = true;
$scope.loadMore = function() {
Articles.all($scope.page).then(function(data) {
var length = data.length;
if(length > 0) {
$scope.articles = $scope.articles.concat(data);
$scope.page++;
if(length < 10) {
$scope.morePageExist = false;
}
}
else {
$scope.morePageExist = false;
}
$scope.$broadcast('scroll.infiniteScrollComplete');
}, function(error) {
console.log(error);
});
};
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment