title: Angular ui modal with controller in separate js file
body: <p>I am trying to make a modal which can be instantiated from multiple places in the app. from the example given here: <a href="http://angular-ui.github.io/bootstrap/#/modal" rel="noreferrer">Angular directives for Bootstrap</a> the modal controller is in the same file as the controller who instantiates the modal. I want to separate the modal controller from the "app" controller.</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html ng-app="modalTest"&gt;
  
    &lt;head&gt;
      &lt;link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"&gt;
    &lt;/head&gt;
  
    &lt;body ng-controller="modalTestCtrl"&gt;
      &lt;button ng-click="openModal()"&gt;Modal&lt;/button&gt;
  
      &lt;script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootstrap-tpls.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="modalTest.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>The controller:</p>
  
  <pre><code>var app = angular.module('modalTest', ['ui.bootstrap']);
  
  app.controller('modalTestCtrl', ['$scope', '$modal', function($scope, $modal) {
      $scope.openModal = function() {
          var modalInstance = $modal.open({
              templateUrl: 'modal.html',
              controller: 'modalCtrl',
              size: 'sm'
  
          });
      }
   }]);
  // I want this in another JavaScript file... 
  app.controller('modalCtrl', ['$scope', function($scope) {
      $scope.hello = 'Works';
  }]);
  </code></pre>
  
  <p>modal.html:</p>
  
  <pre><code>&lt;div ng-controller="modalCtrl"&gt;
      &lt;div class="modal-header"&gt;
          &lt;h3 class="modal-title"&gt;I'm a modal!&lt;/h3&gt;
      &lt;/div&gt;
      &lt;div class="modal-body"&gt;
          &lt;h1&gt;{{hello}}&lt;/h1&gt;
      &lt;/div&gt;
      &lt;div class="modal-footer"&gt;
          &lt;button class="btn btn-primary" ng-click="ok()"&gt;OK&lt;/button&gt;
          &lt;button class="btn btn-warning" ng-click="cancel()"&gt;Cancel&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Is there any way to put the modalCtrl in another JavaScript file and somehow inject the controller (modalCtrl) into the modalTestCtrl ?</p>
  
  <p>BR  </p>