简体   繁体   中英

angularAMD.bootstrap(app) line is throwing an exception in IE10 IE11 browsers but works in Google Chrome

I am trying to implement lazy loading with angularAMD

Plunker please click to reproduce in IE browser

Here is my code. Please help me...

require.config({
  baseUrl: "js/scripts",

  // alias libraries paths.  Must set 'angular'
  paths: {
    'angular': '//ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min',
    'angular-route': '//ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-route.min',
    'angularAMD': '//raw.github.com/marcoslin/bower-angularAMD/v0.1.0/angularAMD.min',
    'ngload': '//raw.github.com/marcoslin/bower-angularAMD/v0.1.0/ngload.min',
    'restangular': '//cdn.jsdelivr.net/restangular/latest/restangular.min',
    'underscore': '//cdn.jsdelivr.net/underscorejs/1.5.2/underscore-min'
  },

  // Add angular modules that does not support AMD out of the box, put it in a shim
  shim: {
    'angularAMD': ['angular'],
    'angular-route': ['angular'],
    'restangular': ['angular', 'underscore']
  },

  // kick start application
  deps: ['app']
});

The problem is caused by IE refusing to load JS unless mime type is set correctly. If you check your IE Developer Tool console, you will see error:

SEC7112: Script from https://raw.github.com/marcoslin/bower-angularAMD/v0.1.0/angularAMD.min.js was blocked due to mime type mismatch

The sample code used is loading JS from raw.github.com which return the file as text/html instead of text/javascript . The solution is simply to recreate the files locally. See:

http://plnkr.co/edit/lmLLiOSGRVxmzSWV0Oh4?p=preview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM