首页 > 解决方案 > 捕获页面是否完全加载在 angularjs 中不起作用(具有多个 ng-repeat 和一个具有大量数据的)

问题描述

我在我的 angularjs 项目中有一个问题我用它来捕捉文档是否准备好

app.directive('resolveApplication', function ($timeout) {
    return {
        restrict: 'A',
        link: function (scope) {
            scope.$$postDigest(function () {
                angular.element(document).ready(function () {
                    $timeout(function () {
                        scope.ngRepeatFinished = true;
                    }, 0)
                });
            });
        }
    }
});


$http.get("api/customers", {}, { params: { partner: partner } }).then(function (response) {
    $scope.customer = response.data.Liste
})

所以我看到文件已加载。但是当我想在我的页面中做一些事情时,我做不到。当我在我的代码中对此进行评论时,它可以完美运行。

PS:$scope.customer 有很多数据,我想问题来自于此,但使用指令我不应该有这个问题。

<div class="form-group">
    <label style="width : 100px">Customer</label>                        
    <select class="form-control SL_Customer">
        <option value="">---Please select---</option>
        <option ng-repeat="option in customer" value="{{option.CustomerUID}}">{{option.Customer}}</option>
    </select>
</div>

更新

当页面未准备好时,我想显示一个进度圈。这个 resolveApplication 指令也应该在 angularjs 完成时捕获。但我的问题是当我使用指令时,我的进度圈在我的选择中插入数据(我猜)结束之前隐藏。

所以在进度圈被隐藏之后,我的选择中仍然插入了一些数据(因为我有很多数据),所以我不能在输入中写入文本,例如。

结果是我可以在我的页面中猜测的 5 秒内做任何事情。

标签: angularjsangularjs-directivedirective

解决方案


推荐阅读