Ionic infinite scroll

前端 未结 2 727
盖世英雄少女心
盖世英雄少女心 2021-01-06 17:14

I am using wordpress as a backend for an app and I want to use infinite scroll but I am having trouble concatenating articles.

I am calling the service using a fact

2条回答
  •  再見小時候
    2021-01-06 18:05

    Try this create a function infiniteScrollCompleteCancelLoadMore and call it when you want to complete the scroll and you have reached the end of your list.

    function infiniteScrollCompleteCancelLoadMore() {
            $timeout(function () {
                $timeout(function () {
                    $scope.$broadcast('scroll.infiniteScrollComplete');
                    $rootScope.canLoad = false;
                });
            });
        }
    
    
    $scope.loadMore = function() {
       Worlds.GetNewPosts().then(function (worlds){
          var loadedIdss = _.pluck($scope.worlds, 'id');
          var newItemss = _.reject(worlds, function (item){ 
             return _.contains(loadedIdss, item.id); 
       });
      $scope.worlds = newItemss.concat($scope.worlds);
      infiniteScrollCompleteCancelLoadMore() // CHANGE HERE  
      });
    };
    

    and your HTML

    
    

    OR call This is you just want to cancel loadMore loop.

    function infiniteScrollComplete() {
            $timeout(function () {
                $timeout(function () {
                    $scope.$broadcast('scroll.infiniteScrollComplete');
                });
            });
        }
    

提交回复
热议问题