title: Inject module dynamically, only if required
body: <p>I'm using Require.js in combination with Angular.js.</p>
  
  <p>Some controllers need huge external dependencies which others don't need, for example, <code>FirstController</code> requires <a href="http://angular-ui.github.io/ui-codemirror/" rel="noreferrer">Angular UI Codemirror</a>. That's a extra 135 kb, at least:</p>
  
  <pre><code>require([
    "angular",
    "angular.ui.codemirror" // requires codemirror itself
  ], function(angular) {
    angular.module("app", [ ..., "ui.codemirror" ]).controller("FirstController", [ ... ]);
  });
  </code></pre>
  
  <p>I don't want to have to include the directive and the Codemirror lib everytime my page loads just to make Angular happy.<br>
  That's why I'm right now loading the controller only when the route is hit, <a href="https://github.com/ifyio/angularjs-lazy-loading-with-requirejs/" rel="noreferrer">like what's done here</a>.</p>
  
  <p>However, when I need something like</p>
  
  <pre><code>define([
    "app",
    "angular.ui.codemirror"
  ], function(app) {
    // ui-codemirror directive MUST be available to the view of this controller as of now
    app.lazy.controller("FirstController", [
      "$scope",
      function($scope) {
        // ...
      }
    ]);
  });
  </code></pre>
  
  <p>How can I tell Angular to inject <code>ui.codemirror</code> module (or any other module) in the app module aswell?<br>
  <strong>I don't care if it's a hackish way to accomplish this, unless it involves modifying the code of external dependencies.</strong></p>
  
  <p><strong>If it's useful:</strong> I'm running Angular 1.2.0.</p>