title: AngularJS can't find my controller
body: <p>I know this is a common problem but I haven't been able to find a solution by reading through previously asked questions.</p>
  
  <p>I'm actually getting two errors but the first one is about angular not being able to find my controller.</p>
  
  <p><a href="http://errors.angularjs.org/1.4.2/" rel="noreferrer">http://errors.angularjs.org/1.4.2/</a>$injector/nomod?p0=myApp.controllers</p>
  
  <p>My directory structure looks like the following:</p>
  
  <pre><code>.
  └── static
      ├── index.html
      ├── js
      │   ├── app.js
      │   └── controllers.js
      ├── lib
      │   └── angular-ui-router.min.js
      └── partials
          ├── view1.html
          └── view2.html
  </code></pre>
  
  <p>My index file looks like the following:</p>
  
  <pre><code>&lt;html ng-app="myApp"&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;Hello AngularJS&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div ui-view&gt;&lt;/div&gt;
          &lt;script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular-route.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="lib/angular-ui-router.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/controllers.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/app.js"&gt;&lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My app.js file looks like the following:</p>
  
  <pre><code>(function(angular) {
  
      var app = angular.module('myApp', ['ui.router', 'myApp.controllers']);
  
      app.config(function($stateProvider) {
          $stateProvider.state('view1', {
              url: '/view1',
              templateUrl: 'partials/view1.html',
              controller: 'View1Controller'
          }).state('view2', {
              url: '/view2',
              templateUrl: 'partials/view2.html',
              controller: 'View2Controller'
          });
      }).run(function($state) {
          $state.go('view2');
      });
  
  })(angular);
  </code></pre>
  
  <p>My controller.js file looks like the following:</p>
  
  <pre><code>(function(angular) {
      var app = angular.module('myApp.controllers');
  
      app.controller('View1Controller', function($scope) {
          $scope.data = 'my view 1';
      });
  
      app.controller('View2Controller', function($scope) {
          $scope.data = 'my view 2';
      });
  
  })(angular);
  </code></pre>
  
  <p>Also a second <a href="http://errors.angularjs.org/1.4.2/$injector/modulerr?p0=myApp&amp;p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.2%2F%24injector%2Fmodulerr%3Fp0%3DmyApp.controllers%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.4.2%252F%2524injector%252Fnomod%253Fp0%253DmyApp.controllers%250A%2520%2520%2520%2520at%2520Error%2520(native)%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A6%253A416%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A24%253A66%250A%2520%2520%2520%2520at%2520a%2520(https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A23%253A109)%250A%2520%2520%2520%2520at%2520P.bootstrap%2520(https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A23%253A352)%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A37%253A451%250A%2520%2520%2520%2520at%2520m%2520(https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A7%253A322)%250A%2520%2520%2520%2520at%2520g%2520(https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A37%253A229)%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A37%253A398%250A%2520%2520%2520%2520at%2520m%2520(https%253A%252F%252Fcdnjs.cloudflare.com%252Fajax%252Flibs%252Fangular.js%252F1.4.2%252Fangular.min.js%253A7%253A322)%0A%20%20%20%20at%20Error%20(native)%0A%20%20%20%20at%20https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A6%3A416%0A%20%20%20%20at%20https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A38%3A154%0A%20%20%20%20at%20m%20(https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A7%3A322)%0A%20%20%20%20at%20g%20(https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A37%3A229)%0A%20%20%20%20at%20https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A37%3A398%0A%20%20%20%20at%20m%20(https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A7%3A322)%0A%20%20%20%20at%20g%20(https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A37%3A229)%0A%20%20%20%20at%20eb%20(https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A40%3A503)%0A%20%20%20%20at%20d%20(https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.2%2Fangular.min.js%3A19%3A339" rel="noreferrer">error</a> which might be related.</p>
  
  <p>As stated above angular is unable to find my controller. Does anyone have a clue about what I'm doing wrong? Please let me know if I need to paste more code.</p>
  
  <p>I've shared the code on github in case someone finds it easier to deal with.</p>
  
  <p><a href="https://github.com/tonsV2/angular-ui.route/tree/master/src/main/resources/static" rel="noreferrer">https://github.com/tonsV2/angular-ui.route/tree/master/src/main/resources/static</a></p>