Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Assignment to read-only properties is not allowed in strict mode in ie 11

I'm have problem with working angular js in ie 11

TypeError: Assignment to read-only properties is not allowed in strict mode at link (ves-min.js:490:7) at Anonymous function (angular.js:7079:34)enter code here at nodeLinkFn (angular.js:6677:13) at compositeLinkFn (angular.js:6071:13) at publicLinkFn (angular.js:5967:30) at link (angular-route.js:919:7) at boundTranscludeFn (angular.js:6091:9)

Please help me some solution, thanks.

like image 490
Le Toan Avatar asked Dec 08 '14 05:12

Le Toan


People also ask

What does the JavaScript strict mode-only exception'is read-only'mean?

The JavaScript strict mode -only exception "is read-only" occurs when a global variable or object property that was assigned to is a read-only property. What went wrong? The global variable or object property that was assigned to is a read-only property.

What is the strict mode of assignment?

In strict mode, any assignment to a non-writable property, a getter-only property, a non-existing property, a non-existing variable, or a non-existing object, will throw an error.

What is strict mode in JavaScript compilers?

Compiling a numeric literal (4 + 5;) or a string literal ("John Doe";) in a JavaScript program has no side effects. It simply compiles to a non existing variable and dies. So "use strict"; only matters to new compilers that "understand" the meaning of it. Why Strict Mode? Strict mode makes it easier to write "secure" JavaScript.

What is the read-only property error in JavaScript?

This error happens only in strict mode code. In non-strict code, the assignment is silently ignored. Read-only properties are not super common, but they can be created using Object.defineProperty () or Object.freeze (). There are also a few read-only properties built into JavaScript.


2 Answers

Add this line in your head tag and do refresh, when It will ask for "allow block content" click "yes".

<meta http-equiv="X-UA-Compatible" content="IE=11" />
like image 90
Shyam_coder Avatar answered Oct 11 '22 22:10

Shyam_coder


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:

(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).

So, you might want to try something like:

(function (angular) {
    "use strict";

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

}(window.angular));​
like image 38
Meligy Avatar answered Oct 12 '22 00:10

Meligy