繁体   English   中英

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

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

我正在运行Angular JS v1.4.7,并且该应用程序在Internet Explorer 10和11中完全崩溃(我们不支持旧版本)。 当我检查控制台时,我看到: Error: [$rootScope:infdig]这里有所解释。

它运行完美,在其他浏览器中没有错误。

经过大量的反复试验后,我能够将问题与其中一个指令中的一个逻辑区分开来,我已将其简化为:

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();
            });
        }
    };
});

我可以通过注释掉setLogoDimensions的最后一行来打开/关闭问题: scope.inlinesvg = $('<div>').append(svg.clone()).html();

来自Angular doc

当应用程序的模型变得不稳定并且每个$摘要周期触发状态更改和随后的$摘要周期时,会发生此错误。 Angular检测到这种情况并防止无限循环导致浏览器无响应。 例如,可以通过在路径上设置监视并随后在值更改时更新相同路径来实现这种情况。

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

在这里,您要修改范围内的inlinesvg模型。$ ​​watch of inlinesvg(抛出setLogoDimensions()函数)。 你不能这样做

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM