Angular JS doesn't work with IE9 but does work with other browsers

So I'm working on a small app that gets this from an API url like ... $ Http.get (s_url) .then (function (res) {... My app works well with chrome, safari, opera and firefox but displays blank screen in IE9 Am I missing something in the html or js file? This 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>

      

+3


source to share


2 answers


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



+8


source


I had a similar problem. The page will load correctly by calling angular to populate the table. subsequent clicks on the refresh button should call the fetch method, but the browser was not ignored.

The solution was to add content expiration headers that expire after 5 seconds and then IE will execute 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 with date and time functions

Depending on what language you are using and what web server yuo is hosted on, there are different ways to do it:



.htaccess file:

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

      

-not, both shouldn't be needed

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");
%>

      

+1


source







All Articles