小编Vis*_*tor的帖子

OrderBy和渐进式加载AngularJS

当我在带有自动增量限制的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>
Run Code Online (Sandbox Code Playgroud)

这是指令:

return function (scope) {
    if (scope.$last) {
        $timeout(function () {
            console.log('Im the last Displayed, Loading more');
            scope.loadMore();
        }, 100);
    }
};
Run Code Online (Sandbox Code Playgroud)

最后是loadMore函数

    $scope.loadMore = function () { …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-ng-repeat angularjs-orderby

5
推荐指数
1
解决办法
404
查看次数