I am using the ioni-infinite scroll component and I I have all my stuff set up correctly. Its seems that the infinite scroll however keeps firing infinitely for some reason. I am trying to have it add 10 item from my model which was already returned to me via ajax during bootstrap.
Below is my code.
$scope.loadMoreDeals = function () {
console.log('Infinite');
if($scope.allDeals.length < AllDeals.allDeals.length){
var startIndex = $scope.allDeals.length - 1;
var endItemNumber = startIndex + 10;
var moreDeals = AllDeals.allDeals.slice(startIndex + 1, endItemNumber);
angular.forEach(moreDeals, function (newDeal, index) {
$scope.allDeals.push(newDeal);
});
}else{
$scope.newDealsExist = false;
}
$scope.$broadcast('scroll.infiniteScrollComplete');
};
and the HTML
<ion-infinite-scroll
ng-if="newDealsExist"
on-infinite="loadMoreDeals()">
</ion-infinite-scroll>
Im not sure what im doing wrong here guys. This is on Beta 14