Utilizing Angular with RequireJS has been quite beneficial for me. I have created concise controllers that contain logic specific to individual modules. However, one drawback is that I am required to include all angular modules in the main layer, which causes a coupling between separate modules and the main layer.
// app.js
define(['angular', 'angularui'], function (angular) {
return angular.module('phx', ['ui.bootstrap'])
});
I am wondering if there is a way to inject ui.bootstrap
at a later stage when the module actually needs it. For example, having the main page only require login and then injecting angularui on pages where necessary:
//dashboard.js
define(['app', 'angularui', function (app) {
// Is there a way to inject ui.bootstrap here without coupling to the main module?
return app.controller('ctrl',
['$scope', function ctrl($scope) {
}];
});