当我在具有自动递增 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);
}
};
对不起我的英语,如果您不明白我的意思或需要更多信息,请告诉我。