Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS IE 8 Support

I'm building a one-page website, using AngularJS, ui-router and jquery, and I need it to support ie 8 browsers.
I followed the instructions from the AngularJS documentation (link), and I also read this and followed its instructions.
In a nutshell: I added this code in the header:

<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="myApp">

and also:

<!--[if lt IE 9]>
    <script type="text/javascript" src="/app/js/3rdparty/html5shiv.js"></script>
    <script type="text/javascript" src="/app/js/3rdparty/json3.min.js"></script>
<![endif]-->

All of my directives are restricted to be used as attribute directives (no custom tags).
But still, no view is being rendered, and no directive is working (on ie8).

I started using ui-router only recently, and the problem existed even before.
I really can't find the problem, and I've searched a lot.
There are many duplicates for this, I know, but none of their solutions helped me (and most of them pretty much refer to angularjs's documentation).
I haven't posted any other code, since there's a lot of it, and I really can't figure out what part of the code (other than the index.html) can be causing any problem.
I'll post any other code if you think it might help.
I'm really lost and would really be grateful if someone could guide me to a solution.
Thank you very much

like image 776
jonny bordo Avatar asked Nov 27 '13 11:11

jonny bordo


2 Answers

In case if you've used any console.log() within your controller or service or factory then IE-8 won't load the angular at all. It's weird.

like image 92
Senthil Avatar answered Oct 03 '22 13:10

Senthil


Seems I made a bit of a fool out of myself.
The problem was that I was using some reserved words, and apparently IE8 really doesn't like it at all.
For instance I had a parameter named "class" on an object, so using obj.class just made IE8 freak out.
The same with a function named "delete" (again inside an object, so I was using functionHoldingObject.delete.

I knew about reserved words, I just didn't think using them as a parameter of an object is harmful. In order to fix this, I just changed the names for some, and used obj["reservedWord"] for others, both solutions work on all browsers.

Another error I found, was that I was using the Array.prototype.indexOf function without knowing that IE8 doesn't support it. So I just added an implementation (which is very easy).
You could get help on that on the MDN site.

like image 38
jonny bordo Avatar answered Oct 03 '22 13:10

jonny bordo