Previous Infinite Scroll

Hi all.
i try to use infinite scroll and it works fine when i scroll down. But my app not showing previous page when im scrolling up. Is somebody has a solution?

This is my code JS

$scope.loadMore = function() {
            $http.get('http://safiahijab.com/wp-json/posts/?page='+$scope.page).success(function(data) {    
                    vm.news = data;
                    console.log("LOAD DATA", data);
                    $scope.$broadcast('scroll.infiniteScrollComplete');
                    console.log($scope.page);
                    $scope.page +=1;
                });
        };

and this is my HTML

<ion-list>
    <div ng-repeat="news in vm.news">
      <a ng-click="selectNews(news.ID)">
            <div class="title-list">{{news.title}}</div>
      </a>
    </div>
  </ion-list>

  <ion-infinite-scroll ng-if="!noMoreItemsAvailable" on-infinite="loadMore()" distance="1%"></ion-infinite-scroll>

Thank you

When you get the data from the server you should append it to the existing vm.news rather than replacing it.

I have a screencast showing a full example here: Ionic Framework: Building a Feed Reader app - Part 4: Infinite scroll and pull-to-refresh

1 Like

Thank ou for your reply. I’ll try

I try to use your code. And it works great. Thank you @encodedmirko