2016-09-23 2 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

Смежные вопросы