Javascript 在 ie 11 中,严格模式下不允许 AngularJS 分配给只读属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27351713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AngularJS Assignment to read-only properties is not allowed in strict mode in ie 11
提问by Le Toan
I'm have problem with working angular jsin ie 11
我在工作angular js时遇到问题ie 11
TypeError: Assignment to read-only properties is not allowed in strict mode at link (
ves-min.js:490:7) atAnonymous function(angular.js:7079:34)enter code hereatnodeLinkFn (angular.js:6677:13)atcompositeLinkFn (angular.js:6071:13) atpublicLinkFn (angular.js:5967:30)at link(angular-route.js:919:7)atboundTranscludeFn (angular.js:6091:9)
类型错误:在链接 (
ves-min.js:490:7) atAnonymous function(angular.js:7079:34)enter code hereatnodeLinkFn (angular.js:6677:13)atcompositeLinkFn (angular.js:6071:13) atpublicLinkFn (angular.js:5967:30)at at link(angular-route.js:919:7)at 的严格模式下不允许分配给只读属性boundTranscludeFn (angular.js:6091:9)
Please help me some solution, thanks.
请帮我解决一些问题,谢谢。
回答by Shyam_coder
Add this line in your head tag and do refresh, when It will ask for "allow block content" click "yes".
在 head 标签中添加这一行并刷新,当它要求“允许阻止内容”时单击“是”。
<meta http-equiv="X-UA-Compatible" content="IE=11" />
回答by Meligy
It could be the following problem:
可能是以下问题:
AngularJS controllers and "use strict"
Maybe it's just that IE 11 respects strict mode, which means if you do something like:
也许只是 IE 11 尊重严格模式,这意味着如果您执行以下操作:
(function () {
"use strict";
function webAddressController($scope, $rootScope, web_address_service) {
// Do things
}
}());
The webAddressControllerfunction is not in global scope for Angular to pick (the point of using the self executing syntax is to avoid adding things to global scope).
该webAddressController函数不在 Angular 选择的全局范围内(使用自执行语法的目的是避免向全局范围添加内容)。
So, you might want to try something like:
因此,您可能想尝试以下操作:
(function (angular) {
"use strict";
angular.module('myApp').controller('webAddressController', function($scope) {
// Do things
});
}(window.angular));?

