简体   繁体   English

Angular JS错误:仅限IE 10和IE 11中的[$ rootScope:infdig]

[英]Angular JS Error: [$rootScope:infdig] in IE 10 and IE 11 only

I'm running Angular JS v1.4.7 and the app completely crashes in Internet Explorer 10 and 11 (we don't support older). 我正在运行Angular JS v1.4.7,并且该应用程序在Internet Explorer 10和11中完全崩溃(我们不支持旧版本)。 When I check the console I see: Error: [$rootScope:infdig] which is somewhat explained here . 当我检查控制台时,我看到: Error: [$rootScope:infdig]这里有所解释。

It runs perfectly with no errors in other browsers. 它运行完美,在其他浏览器中没有错误。

After a lot of trial and error I was able to isolate the problem to a single bit of logic in one of the directives, which I've simplified: 经过大量的反复试验后,我能够将问题与其中一个指令中的一个逻辑区分开来,我已将其简化为:

tsApp.directive('svgIcon', function($timeout) {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            inlinesvg: '=',
            orientation: '@',
            themeid: '@',
            scale: '@',
            verticalAlign: '@'
        },
        template: '<span ng-bind-html="inlinesvg | unsafe"></span>',
        link: function(scope, element, attrs) {

            /* @TODO Synchronize with similar function in Mode Icon directive */
            /* Function updates inlinesvg to avoid flicker */
            scope.setLogoDimensions = function() {
                /* Obtain svg attributes */
                var svg = angular.element(scope.inlinesvg);
                /* ... */
                /* Reinsert raw svg with jQuery conversion */
                scope.inlinesvg = $('<div>').append(svg.clone()).html();
            };

            /* Resize if new inlinesvg */
            scope.$watch('inlinesvg', function() {
                scope.setLogoDimensions();
            });
        }
    };
});

I can turn the problem on/off by commenting out the final line of setLogoDimensions : scope.inlinesvg = $('<div>').append(svg.clone()).html(); 我可以通过注释掉setLogoDimensions的最后一行来打开/关闭问题: scope.inlinesvg = $('<div>').append(svg.clone()).html();

From Angular doc 来自Angular doc

This error occurs when the application's model becomes unstable and each $digest cycle triggers a state change and subsequent $digest cycle. 当应用程序的模型变得不稳定并且每个$摘要周期触发状态更改和随后的$摘要周期时,会发生此错误。 Angular detects this situation and prevents an infinite loop from causing the browser to become unresponsive. Angular检测到这种情况并防止无限循环导致浏览器无响应。 For example, the situation can occur by setting up a watch on a path and subsequently updating the same path when the value changes. 例如,可以通过在路径上设置监视并随后在值更改时更新相同路径来实现这种情况。

$scope.$watch('foo', function() { $scope.foo = $scope.foo + 1; }); $ scope。$ watch('foo',function(){$ scope.foo = $ scope.foo + 1;});

Here, you are modifiying your inlinesvg model inside your scope.$watch of inlinesvg (threw your setLogoDimensions() function). 在这里,您要修改范围内的inlinesvg模型。$ ​​watch of inlinesvg(抛出setLogoDimensions()函数)。 You can't do that 你不能这样做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 angular.js:10126错误:[$ rootScope:infdig]达到10个$ digest()迭代。 流产! nvd3 js错误 - angular.js:10126 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! error with nvd3 js Array.sort角度滤镜和“错误:[$ rootScope:infdig]达到10个$ digest()迭代。 中止!” - Array.sort angular filter and “Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!” $rootScope:infdig angularjs 中的错误 - $rootScope:infdig Error in angularjs 带有 Angular 10(非 CLI)的 IE11 上的语法错误 - Syntax error on IE11 with Angular 10(non-CLI) Angular JS和IE11 - Angular JS and IE11 AngularJS:未捕获的错误:[$ rootScope:infdig]达到10个$ digest()迭代 - AngularJS: Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached IE 10/11和Angular 2的Edge Shim - IE 10/11 and Edge Shim for Angular 2 angular 中的 [$rootScope:infdig] 或 [$rootScope:inprog] 是什么意思? - what [$rootScope:infdig] or [$rootScope:inprog] in angular mean? app.min.js:7错误:[$ rootScope:infdig]达到10个$ digest()迭代。 流产! 观察者在最近5次迭代中被解雇 - app.min.js:7 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations $ rootScope:AngularJS应用程序中的infdig错误 - $rootScope:infdig error in angularjs application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM