Angular JS "SCRIPT5007: Object expected" error in IE9 and IE10 upon loading the angular library
Asked Answered
C

1

9

I am developing an AngularJS application that should run on Firefox and IE 9 and IE 10. I use the latest version of angularjs library (now it is 1.3.15). The serverside is written in Java in JavaEE platform and server runs on GlassFish, and our computers run windows 7.

Everything works fine when I am running the server locally on my computer and access my application using the http://localhost:8080 url.

But in IE9 and IE10, when I try to load the application from my server by using my ip address (something like http://191.10.10.200:8080) then angularJS library fails to load. It gives an error saying:

SCRIPT5007: Object expected angular.min.js, line 7 character 218

Can this be an issue with the security settings of IE? Or the network? I looked for similar issues but none was talking about this problem. Please help me if have an idea how can this be resolved.

Centrosphere answered 20/4, 2015 at 13:57 Comment(6)
Have you tried running this with the unminified version of Angular to get a better error message? You could see where it was failing at.Acephalous
Thanks you, yes. Then I get the same error. This time in line 335 character 12. That is in forEach function where isArray object is being checked, So the expected object should be isArray. isArray is defined in line 599.Centrosphere
So without seeing exactly what is causing the issue here, it is difficult to say. I would suggest opening up the Dev tools (F-12) and putting a breakpoint on that line so you can see exactly what it is complaining about.Acephalous
When you load the page using the IP address, is the document mode (as reported by the F12 tools) the same as it is when you load the page from localhost? If not, then you're running into a situation where the way you load your page changes the rendering context. Use MotW to ensure the page is loaded from the Internet zone and use x-ua-compatible to ensure that the correct docmode is enabled.Plerre
Thank you very much for your replies. Yes @LanceLeonard, that seems to have been the problem. IE was running in IE7 document mode when accessing the server through IP. So by using the meta tag <meta http-equiv="X-UA-Compatible" content="IE=edge"></meta> it is forced to use the latest document mode and thus angularjs library loads correctly.Centrosphere
I encountered the same error while running from localhost:60245 during development after installing the latest version of angular 1.3.15 The solution was the same: <meta http-equiv="X-UA-Compatible" content="IE=edge">Waterproof
L
2

I had the same error which only occurred in IE9 and IE10 when I was loading a page requiring AngularJS.

My page was simply missing the DOCTYPE header from the top of the page:

<!DOCTYPE html>

Once I added it AngularJS loaded just fine for me.

Lulululuabourg answered 11/1, 2016 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.