1

我正在使用 AngularJS,我在这里有一个小问题。我刚刚让我的 httpInterceptor 服务在执行 ajaxRequests 时在网页上显示一个微调器,但是当我使用 IE 在 iF​​rame 中运行它时出现这个错误;使用 Chrome、Firefox 不会发生这种情况。这是拦截器的代码:

.factory('httpInterceptor', function ($q, $rootScope) {
        return function (promise) {
            $rootScope.$$childHead.spinner += 1;
            return promise.then(function (response) {
                $rootScope.$$childHead.spinner -= 1;
                return response;
            }, function (response) {
                $rootScope.$$childHead.spinner -= 1;
                return $q.reject(response);
            });
        };
    }).config(function ($httpProvider) {
        $httpProvider.responseInterceptors.push('httpInterceptor');
        var spinnerFunction = function (data, headersGetter) {
            return data;
        };
        $httpProvider.defaults.transformRequest.push(spinnerFunction);
    });

出于某种原因,当我在 iFrame 中运行我的应用程序时,它会向我显示此错误:

Error: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations:

我想知道这是因为在 iFrame 中运行它还是因为 promise 对象造成的。

我在使用 ng-repeat 时看到了这个错误,但我还没有找到原因。如果你有类似的问题,请给我一些建议。谢谢!

4

1 回答 1

1

在引用 $rootScope.$$childHead 时,您似乎正在陷入角度。如果这是一个内部构造,那么这很可能是您的问题。你似乎在用角度来更新同一个字段。看到这个解决方案

于 2012-10-31T16:11:51.077 回答