Reputation:
I have put my controllers of my angular app in separate files:
This is my project structure:
This is bootstrap.js:
angular.module('controllers', []);
I have this in every controller file:
angular.module('controllers')
.controller('UserCtrl', ['$scope', '$state', 'auth',
function ($scope, $state, auth) {
------
In my app.js I have this:
var app = angular.module('eva', ['ui.router','ngMaterial', 'controllers']);
-----------
At first every controller was in my app.js file, which worked perfectly. Now it doesn't load the controllers, how is this possible?
Upvotes: 1
Views: 554
Reputation: 885
Add .js file in your first loading HTML file(index.html) The orders in writing this scripts are important, too. If you have dependency they should come before modules. and controller come after module. in you case, it will be like this:
<script src="scripts/angularjs.min.js"></script>
<script src="scripts/controllers/bootstrap.js"></script>
<script src="scriptscontrollers/Appcontroller.js"></script>
// the rest of your controler script files which are part of bootstrap.js or controllers module.
<script src="scripts/app.js"></script>
Upvotes: 0
Reputation: 3542
Add the .js files for the new controllers in your HTML page and it'll work again.
Upvotes: 1