Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGeorge Akinian
17,615 PointsU can't have that semicolon at the end of a controller if you plan on writing another controller after the initial
Cheers.
1 Answer
Donald Brunais
8,895 PointsYou still can. You just have to call module angular.module again.
angular.module('myApp', [])
.controller('controllerName', controllerFunction);
angular.module('myApp')
.controller('anotherControllerName', anotherControllerFucntion);
The first time you need to pass the array that will inject all your dependencies. The second time you do not, you are just getting your angular module. You will have to do something like this when you apps start to get larger and you need to break them out into different files. You might want to check out John papa's style guide. It has best practices on how you should lay out your angular app. https://github.com/johnpapa/angular-styleguide
Pierre Smith
11,842 PointsPierre Smith
11,842 PointsYou also can assign the module to a var for simplicity like this
concatenate them like this:
or create them individually like this