2016-09-23 14 views
0
$scope.loadNotification = function(page) { 
    showLoader(true); 
    NotificationService.getNotification(page).then(function(response) { 
     showLoader(false); 
     var data = response.data, notifications = data.notifications, nextPage = data.nextPage;   
     renderNotification(notifications, nextPage); 
    }, function(error) { 
     showLoader(false); 
     $scope.pageMesssag = error; 
     $scope.reloadNotificationBtn=true; 
    }); 
} 

$scope.loadNextPage = function() { 
    $scope.loadNotification($scope.nextPage); 
} 

function renderNotification(notifications, nextPage) { 
    $scope.nextPage = nextPage; 
    if(nextPage === 0 && notifications.length === 0) { 
     $scope.pageMesssag = Utils.prepareErrorMessage('', "No notifications so far."); 
    } else if(nextPage !== 0 && nextPage === undefined){ 
     $scope.pageMesssag = Utils.prepareErrorMessage('', "No more notifications available."); 
    } 
    $scope.notifications.push.apply($scope.notifications, notifications); 
    var slicedNotidications = $scope.notifications; 
    if(slicedNotidications.length > PAGINATION_SIZE) { 
     slicedNotidications = slicedNotidications.slice(0, PAGINATION_SIZE); 
    } 
    angular.forEach(notifications, function(value, key) { 
     if(!value.read) { 
      readNotifications.push(value.id); 
     } 
    }); 
    NotificationService.storeLatestNotificcations(slicedNotidications, nextPage); 
    if(readNotifications.length > 0){ 
     markNotification(readNotifications);     
    }  
    console.log("---"+$scope.nextPage); 
} 

這裏是我的html代碼:離子無限沒有得到所謂的

<ion-infinite-scroll ng-if='nextPage !== undefined' on-infinite="loadNextPage()" distance="10%"></ion-infinite-scroll> 

loadNextPage是沒有得到所謂的,即使nextPage有一定的價值

回答

0

似乎下一頁的,這就是爲什麼一開始是不確定的loadNextPage沒有被調用。您需要將$ scope.nextPage設置爲RenderNotification函數外的某個值。

+0

'console.log(「---」+ $ scope.nextPage);'正在打印某個值 – manish