Reputation: 500
I have my RequireJS config like below. First I want to load AngularJS, then my bootstrap app.js and then the two controllers, but it won't load the second file in the array.
What do I do wrong?
require.config({
baseUrl: '/js/app',
paths: {
'angular': '/js/vendor/angular/angular.min',
'controllers': ['controllers/CartController', 'controllers/CatalogController']
},
shim: {
'angular': {
exports: 'angular'
},
'app': {
deps: ['angular']
},
'controllers': {
deps: ['app'],
}
},
});
require(['controllers'], function () {
angular.bootstrap(document, ['MyApp']);
});
Thanks for your help!
Upvotes: 1
Views: 1329
Reputation: 40296
The array notation for paths
is used for content loaded from CDN; so RequireJS will try the first entry in the array (the CDN) and, if that is down, will fall back to the second (supposedly served by your own servers).
For including all the controllers from one dependency, you will probably have to create a dummy (empty) controllers.js
, add a path to it, and shim it as:
shim: {
'controllers': {
deps: ['controllers/CartController', 'controllers/CatalogController']
}
}
Upvotes: 4