Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 error in IE11

Tags:

angular

I have Angular 4 project that works successfully on Chrome. However it doesn't load on IE11 with the following error in polyfills.bundle.js(I use command "ng build --env=prod" to build site):

var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {   var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);   var f = ctx(fn, that, entries ? 2 : 1);   var index = 0;   var length, step, iterator, result;   if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); 

iterFn is undefined here so error is thrown. Please advise.

like image 424
Sergiy Avatar asked Sep 04 '17 11:09

Sergiy


People also ask

Is Angular compatible with IE11?

By default, Angular compiles ES6 or ES7. IE 11 only supports ES5.

Why Angular is not working in IE?

The reason for this error was IE was running in compatibility mode and in that mode it's running with older version of JavaScript which does not support “querySelector.”. In order to fix the issue: Simply turn off the compatibility mode in IE and you should be good to go !

How do I get Angular app to work in IE?

As you can see, to support IE 11, you need to add es5BrowserSupport property in angular. json file and change the target as es5 in tsconfig. json file that solved the problem. Let me know in the comments if you have questions.


1 Answers

For better support of IE11 you need to add some es6 imports exclusively in your polyfills. List is as follows:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/ import 'core-js/es6/symbol'; import 'core-js/es6/object'; import 'core-js/es6/function'; import 'core-js/es6/parse-int'; import 'core-js/es6/parse-float'; import 'core-js/es6/number'; import 'core-js/es6/math'; import 'core-js/es6/string'; import 'core-js/es6/date'; import 'core-js/es6/array'; import 'core-js/es6/regexp'; import 'core-js/es6/map'; import 'core-js/es6/weak-map'; import 'core-js/es6/set'; 
like image 159
Sumit Agarwal Avatar answered Sep 20 '22 20:09

Sumit Agarwal