按需載入 n 個可用資料
HTML:
<li class="item" ng-repeat="schedule in Schedules | filter:scheduleSearch | limitTo:numberOfItemsToDisplay">
Display some data
</li>
<ion-infinite-scroll on-infinite="addMoreItem()" ng-if="Schedules.length > numberOfItemsToDisplay"></ion-infinite-scroll>
控制器:
$scope.numberOfItemsToDisplay = 10; // Use it with limit to in ng-repeat
$scope.addMoreItem = function(done) {
if ($scope.Schedules.length > $scope.numberOfItemsToDisplay)
$scope.numberOfItemsToDisplay += 10; // load number of more items
$scope.$broadcast('scroll.infiniteScrollComplete')
}
每次 addMoreItem()
呼叫時載入 10 個專案。