Angular 6 project not loading in IE11

2020-03-27 10:58发布

问题:

My angular 6 project loads in chrome but it does not load in IE11. I used the following question: Angular 2 / 4 / 5 not working in IE11 to try and solve the issue but none of the suggested solutions helped. Here is a list of the imports I have in polyfills.

1) I uncommented all of the imports in my polyfills.ts and ran the appropriate npm install commands. 2) I added the following line in my index.html

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

3) And I also turned off the "Display intranet sites in Compatibility View" in IE11 as suggested in the post

but none of the following solutions helped.

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';

import 'classlist.js';  

import 'core-js/es6/reflect';
import 'core-js/es7/reflect';

import 'web-animations-js';

import 'zone.js/dist/zone';

Any ideas on what I may be missing since this is an Angular 6 project?

回答1:

Did you verify that any subscribe function that is running outside of your ts files are using

.subscribe(function(data) { });

instead of

.subscribe((data) => {});

IE is not able to execute this style of anonymous function properly.

Also make sure you are not using any ES6 components outside of your angular app without having a shim to handle them (https://kangax.github.io/compat-table/es6/)



回答2:

An update of angular-cli, webpack might be helpful.

I have solved an issue in IE 10. Reference: TypeError: Unable to get property 'ngMetadataName' of undefined or null reference on IE 10



回答3:

I followed the suggestion to comment out code until my App started in IE 11.

I had an image path in my menu component that was causing the issue. Sorted the path and the app started.