I am trying to figure out why my angular 2 app is stuck on showing Loading... when running in IE 11.
Following someone's suggestion, I've tried this plunker, posted by someone on stack overflow, on both chrome and IE 11. Works fine on Chrome, but fails on IE 11. Same error, stuck on saying "Loading..."
The plunker is : https://plnkr.co/edit/6zVFbrH5yohwc714gBbk?p=preview
<!DOCTYPE html>
<html>
<head>
<script>document.write('<base href="' + document.location + '" />');</script>
<title>Router Sample</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/tools/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.1/http.dev.js"></script>
<script>
System.config({
transpiler: 'typescript',
typescriptOptions: { emitDecoratorMetadata: true },
packages: {'src': {defaultExtension: 'ts'}}
});
System.import('src/boot')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<my-app>loading...</my-app>
</body>
</html>
Anybody got any idea as to why IE 11 fails to run the angular 2 app?
Thank you!
For me with iexplorer 11 and Angular 2 I fixed all those above issues by doing 2 things:
in index.html add:
in src\polyfills.ts uncomment:
As of Feb 2017
Using an Angular-Cli project, all lines in the
polyfills.ts
file were already uncommented so all polyfills were already being utilised.I found this solution here to fix my issue.
To summarize the above link, IE doesn't support lambda arrow / fat arrow functions which are a feature of es6. (This is if polyfills.ts doesn't work for you).
Solution: you need to target es5 for it to run in any IE versions, support for this was only introduced in the new Edge Browser by Microsoft.
This is found under
src/tsconfig.json
:As of September 2017 (node version=v6.11.3, npm version=3.10.10), this is what worked for me (thanks @Zze):
Edit
polyfills.ts
and uncomment the imports that are necessary for IE11.More preciselly, edit
polyfills.ts
(located in thesrc
folder by default) and just uncomment all lines required for IE11 (the comments inside the file explain exactly what imports are necessary to run on IE11).A small warning: pay attention when uncommenting the lines for
classlist.js
andweb-animations-js
. These commented lines have a specific comment each: you must run the associated npm commands before uncommenting them or processing of polyfills.ts will break.As a word of explanation, the polyfills are pieces of code that implement a feature on a web browser that do not support it. This is why in the default polyfills.ts configuration only a minimal set of imports is active (because it's aiming the so-called "evergreen" browsers; the last versions of browsers that automatically update themselves).
I had the exact same issue and none of the solutions worked for me. Instead adding the following line in the (homepage).html under
<head>
fixed it.If none of the other solutions work for you, it's worth investigating the source of the problem. It may be than an npm module directly inserts ES6 code, which cannot be transpiled.
In my case I had the
SCRIPT1002: Syntax error vendor.js (114536,27) at the following line:
I searched the node_modules folder and found from which file the line came. It turned out that the culprit was punycode.js which in it's 2.1.0 version uses ES6 directly.
After I downgraded it to 1.4.1, which uses ES5, the problem was solved.
I ran into this issue today. I found an solution on GitHub that does not require going to a later version of the beta.
Add the following script to your html:
This resolved the problem for me. For more details, you can follow the github issue here: https://github.com/angular/angular/issues/7144