I'm having a bit of trouble regarding the creation of an infinite scroll in angularJS from a JSON file generated on an external site. What I need is that the infinite scroll be called when the item of variable posts
is equal to 10, calling my function again, incrementing +1 in the URL, changing the page. Here is the code:
$scope.posts = [];
$scope.doRefresh = function(){
JsonNews.getBlogs($scope);
$scope.$broadcast('scroll.refreshComplete');
}
$page = 0;
function JsonNews($http, $log){
$page++;
$urlInfinite = "http://plantaojti.com.br/noticias/page/"+ $page +"/?feed=json&callback=JSON_CALLBACK";
this.getBlogs = function($scope){
$http.jsonp($urlInfinite).success(function(data){
$scope.posts = data;
for (var i = 0; i < $scope.posts.length; i++) {
this.posts.push(posts[i].data);
}
AppCtrl.$scope.doRefresh($scope);
});
}
}
No HTML:
<div infinite-scroll='JsonNews()' inite-scroll-distance='1'>
<ion-item data-ng-repeat="item in posts | filter: query" class="item-thumbnail-left item-text-wrap item-icon-right" href="window.open('{{item.permalink}}', '_system', 'location=yes'">
<img class="thumb-noticia" data-ng-src="{{item.thumbnail}}">
<h2> {{item.title}} </h2>
<p>{{item.excerpt | limitTo: 100}}...</p>
</ion-item>
</div>