Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Well, I have created site using Angular 2. When I run "ng-serve" command and trying to test my site using "http://localhost:4200" in Google Chrome and IE11 it works perfectly, but, if I build project using "ng-build --prod", host it on IIS. Site still works on Chrome, but IE11 shows the following errors: Expected identifier, string or number

I googled it and found that it was maybe reserved words in my identifiers key:value pairs. So I added Apostrophes(') arround my keys. For example I had the following object:

user:UserViewModel={
    Username:"",
    Age:0
};
and changed this to:
user:UserViewModel={
    'Username':"",
    'Age':0
};

Also deleted last commas in key:value pairs and imported core.js in polyfills.ts

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

The main problem is IE has Compatibility Mode enabled by default. And IE 11 has some compatibility mode issues. As per the followings question answer Angular 2 / 4 not working in IE11

When I tried to disable the compatibility mode off It works fine.

But ingeneral user will not off the compatibility mode. So I want a good solution for that.

Then I found following solution form Force IE compatibility mode off using tags

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...