Angular add modules after angular.bootstrap

angularjs, meteor

Solution

Create your module:

angular.module('app.controllers', []);

Add it as a dependency:

angular.module('app').requires.push('app.controllers');

Problem

I'm using meteor + angular. My intention is to add more dependencies after the app bootstrap (This is because the package is the one handling the bootstrapping at the start and I don't have much control of it). Now while doing that, I would also want to enforce a basic code structure wherein for example, I would compile all controllers in one module. Here's the basic idea: ``` 'use strict'; angular.module('app.controllers', []) .controller('MainCtrl', function() { // ... }) .controller('SubCtrl', function() { // ... }) .controller('AnotherCtrl', function() { // ... }); ``` Then include that to the main module as dependency: ``` angular.module('app', [ 'app.filters', 'app.services', 'app.directives', 'app.controllers' // Here ]); ``` After some research, I've discovered that what I'm trying to do (Adding dependencies after bootstrap) is actually a part of a feature request to the angular team. So my option is using, for example, `$controllerProvider` and `register()` function: ``` Meteor.config(function($controllerProvider) { $controllerProvider.register('MainCtrl', function($scope) { // ... }); }); Meteor.config(function($controllerProvider) { $controllerProvider.register('SubCtrl', function($scope) { // ... }); }); Meteor.config(function($controllerProvider) { $controllerProvider.register('AnotherCtrl', function($scope) { // ... }); }); ``` It's works though not that elegant. The questions are: - What's a more elegant way of doing the `config` and `register` part? - Is there a way to register a module instead?

Original source