自動インクリメント limitTo を使用して ng-repeat で orderBy を使用すると問題が発生します。ページがいくつかの要素をロードすると、ディレクティブは機能を停止し、要素の制限の増加を停止します。
これはhtmlです:
<div class="row" id="main">
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-2 block animate"
ng-if="!errorDialogActive"
ng-repeat="build in builds.builds.build | limitTo:totalDisplayed | orderBy:'lastBuildDetails.startDate' : true track by build._id"
ng-class="{'running': project.running ,'block-green': build._status ==='SUCCESS','block-red': build._status==='FAILURE'}"
id="{{build._id}}"
progressive-loading>
<div class="title-container animate" ><p>{{build._buildTypeId}}</p></div>
<div class="update-container animate col-xs-12">
<time class="time">{{build.buildDate | date : 'dd.MM.yyyy H:mm:s'}} </time>
</div>
</div>
</div>
これはディレクティブです:
return function (scope) {
if (scope.$last) {
$timeout(function () {
console.log('Im the last Displayed, Loading more');
scope.loadMore();
}, 100);
}
};
そして最後に loadMore 関数
$scope.loadMore = function () {
if ($scope.totalDisplayed >= $scope.size) {
console.log('no more builds : ' + $scope.totalDisplayed);
$scope.loaded=true;
} else {
$scope.totalDisplayed += 2;
console.log('More : ' + $scope.totalDisplayed);
$scope.totalDisplayedPercentage = (($scope.totalDisplayed*100)/$scope.size);
console.log('Percentage : ' + $scope.totalDisplayedPercentage);
}
};
私の英語で申し訳ありませんが、私が理解できない場合、またはさらに情報が必要な場合は、お知らせください。