Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tutorial App part 4 - CategoryCtrl
.controller('CategoryCtrl', ['$scope', '$stateParams', 'Categories', function($scope, $stateParams, Categories) {
$scope.page = 0;
$scope.articles = [];
$scope.category = false;
$scope.morePageExist = true;
$scope.loadMore = function() {
Categories.get($stateParams.catId, $scope.page).then(function(data) {
var length = data.length;
if(!$scope.category) {
$scope.category = data[0];
}
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
You can’t perform that action at this time.