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: