【问题标题】:AngularJS Assignment to read-only properties is not allowed in strict mode in ie 11AngularJS ie 11 中严格模式下不允许对只读属性赋值
【发布时间】:2015-02-05 17:42:24
【问题描述】:

我在 ie 11 中工作 angular js 时遇到问题

TypeError:在严格模式下不允许在链接 (ves-min.js:490:7) Anonymous function (angular.js:7079:34)enter code here nodeLinkFn (angular.js:6677:13) compositeLinkFn (angular.js:6071:13) 处分配给只读属性publicLinkFn (angular.js:5967:30) 链接(angular-route.js:919:7) boundTranscludeFn (angular.js:6091:9)

请帮我解决一下,谢谢。

【问题讨论】:

  • 你可以使用你的代码的非缩小版本并在你抱怨的代码中发布相关部分吗?
  • 嗨@Le Toan,您的问题太模糊,无法理解确切的问题在哪里。您能否提供更多详细信息,例如代码快照、什么不起作用等。我确实在 IE11 中使用了 AngularJS,它运行良好。因此,说 AngularJS 不能在 IE11 中工作是不恰当的。请提供有关您的问题的完整详细信息。

标签: javascript angularjs internet-explorer-11 ie11-developer-tools


【解决方案1】:

在你的头标签中添加这一行并刷新,当它会要求“允许阻止内容”时点击“是”。

<meta http-equiv="X-UA-Compatible" content="IE=11" />

【讨论】:

  • 对于未来的搜索者 - 此解决方案结合将 app.js 的脚本移动到底部,即 应该是最后一个脚本(抱歉,我在 SO 上找不到有人指出这一点的地方。这两个动作相结合为我解决了一个“噩梦”问题!
【解决方案2】:

可能是以下问题:

AngularJS controllers and "use strict"

也许只是 IE 11 尊重严格模式,这意味着如果您执行以下操作:

(function () {
    "use strict";

    function webAddressController($scope, $rootScope, web_address_service) {
        // Do things
    }

}());

webAddressControllerfunction 不在全局范围内供 Angular 选择(使用自执行语法的目的是避免向全局范围添加内容)。

因此,您可能想尝试以下方法:

(function (angular) {
    "use strict";

    angular.module('myApp').controller('webAddressController', function($scope) {
        // Do things
    });

}(window.angular));​

【讨论】:

  • 谢谢Meligy,我现在没事了。
  • 那么,请您标记答案吗? :) 谢谢!
  • (我的意思是点击答案前面的勾号,谢谢!)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-01-01
  • 1970-01-01
  • 2017-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多