-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
The context is the first lines of the script related to the module definition:
(function(angular, factory) {
if (typeof define === 'function' && define.amd) {
define('angular-file-upload', ['angular'], function(angular) {
return factory(angular);
});
} else {
return factory(angular);
}
}(angular || null, function(angular) {
If you load "angular-file-upload" with an AMD such as requirejs, and you don't manually set angular as a dependency using a shim in your requirejs configuration, then the initialization of "angular-file-upload" fails, since angular is undefined - in particular, the browser (Chrome 35) throws the following exception at you:
Uncaught ReferenceError: angular is not defined angular-file-upload.js:13
Aside from applying the shim in my own code like this:
require.config({
paths: {
"angular" : "relative/path/to/angular",
"angular-file-upload" : "relative/path/to/angular-file-upload",
... other modules
},
shim: {
"angular": {
exports: "angular"
},
// Currently needed
"angular-file-upload": ["angular"]
}
})
A working fix for angular-file-upload is to change:
(angular || null, function(angular)
to:
(window.angular, function(angular)
... but I have a feeling there is a prettier solution to this.
However, if I do this, then I don't need to manually set angular as a dependency in my requirejs configuration - and I can start using the module defined in angular-file-upload instead (which then makes sure to resolve angular correct when loaded).
Aside from that - thanks for a great library - good job :)
Update:
Maybe the suggested fix is not that bad at all: http://stackoverflow.com/a/13469729/700926