1

私はAngularJSを使用していますが、ここで少し質問があります。httpInterceptorサービスを作成してajaxRequestsを実行するときにWebページにスピナーを表示しましたが、IEを使用してiFrame内で実行するとこのエラーが発生します。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 に答える