3

So I am working on a small app that gets that from an API url like so... $http.get(s_url) .then(function(res) {... My app works well with chrome,safari,opera and firefox but displays a blank screen in IE9 Am I missing something in my html or js file? Here is what I have in my html file for IE...

    <!--[if lte IE 8]>
    <script src="js/json2.js"></script>
    <script>
        document.createElement('ng-include');
        document.createElement('ng-pluralize');
        document.createElement('ng-view');
        document.createElement('x-restrict');
        document.createElement('x-fileupload');
        // Optionally these for CSS
        document.createElement('ng:include');
        document.createElement('ng:pluralize');
        document.createElement('ng:view');
        //customized tags
        document.createElement('location');
        document.createElement('temp');
        document.createElement('image');
        document.createElement('caption');
        document.createElement('temps');
        document.createElement('remtemps');
    </script>
    <![endif]-->
    <div ng-view></div>
</head>
Toni
  • 740
  • 2
  • 8
  • 14
  • This only handles IE versions up to IE 8? –  Oct 25 '14 at 22:43
  • I only need it to handle IE9 and upwards – Toni Oct 25 '14 at 23:02
  • Let me reiterate: None of the code in your snippet is run in IE9. Is this intentional? –  Oct 25 '14 at 23:06
  • 1
    Ah, yes, there we have it: `if lt IE 9` matches versions "less than IE 9" - that is, it matches the same thing as `if lte IE 8`. If you want to run the first block in IE 9, it should be just `if IE 9`. –  Oct 25 '14 at 23:20
  • Thanks for the catch. It still gives me a blank screen on IE9. It looks like the app successfully makes the $http.get call but there seems to be an issue with modifying my html code so that it works with IE9. – Toni Oct 25 '14 at 23:27
  • looking in the wrong place. IE9 can handle the custom tags – charlietfl Oct 25 '14 at 23:50
  • Ok so what do I have to change in a html file that works on other browsers in order for it to work on IE9 and upwards? – Toni Oct 25 '14 at 23:57
  • look in developer tools for errors. If `
    ` is in head as shown, there's a big problem. Also make sure you haven't left any trailing commas in arrays and objects which is always a blocker in older IE versions that will throw errors. I have built numerous angular apps and all work fine in IE 9.
    – charlietfl Oct 26 '14 at 10:37

2 Answers2

8

Try prefixing ng-app and ng-view with data as in data-ng-app, data-ng-view.

Srinivas Paila
  • 817
  • 6
  • 10
  • 2
    Thanks. I added that to my code. The main issue was with the http.get method which has some issues with IE so I had to use XMLHttpRequest(). – Toni Oct 26 '14 at 02:45
1

I had a similar issue. The page would load properly, calling angular to populate a table. subsequent clicks on a refresh button should recall the fetching method, but were ignored by the browser.

The resolution was to add content expiry headers expiring 5 seconds in the past, and then IE would execute the Angular scripts.

EDIT:

How to implement

The headers to add are specified in the HTTP specification.

I have printed a fixed timestamp here. You can of course set the date explicitly using date/time functions

Depending on which language you are using, and which webserver yuo are hosted on, there are different ways to do this:

.htaccess file:

<filesMatch "\.json">
   Header set Cache-Control "max-age=0, public"
   Header set Expires "Thu, 01 Dec 1994 16:00:00 GMT"
</filesMatch>

-note both shouldn't be necessary

if you are using php:

<? header("Expires: Thu, 01 Dec 1994 16:00:00 GMT");
   header("Cache-Control: max-age=0, public");  
?>

if you are using jsp:

<% 
   response.setHeader("Cache-Control: max-age=0, public");
%>
JoSSte
  • 2,953
  • 6
  • 34
  • 54
  • could you please provide how exactly you added content expiry headers expiring 5 seconds in the past? – kiriz Jul 30 '15 at 14:53
  • I have edited my answer with sample code. hope that it helps – JoSSte Jul 31 '15 at 12:28
  • Thanks. Though I am using .NET. I found a solution [here](http://www.visualstudiogeeks.com/blog/angularjs/mvc/ie/angularjs-and-ie9/). I added a time stamp to every `$http.get` call and that did the trick. – kiriz Jul 31 '15 at 12:54
  • Great to hear that you found a solution – JoSSte Jul 31 '15 at 13:41
  • Even i face the same problem with angularjs in IE<=9 versions. I am not able to load the angular scripts itself. I used ng-app and ng-controller, I am trying to export a html table to excel file. But no luck. can anyone help, or give a suggestion please? – Disera Apr 11 '16 at 10:32