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 trialHamed Ali
5,626 Pointsneed help with creating a controller
Create new controller called "coolCtrl"
Im not sure what I am doing wrong here
angular.module('foobar', []);
.controller('coolCtrl', function());
2 Answers
Paul Jackson
7,585 PointsHi Hamed,
There are a few ways to define a controller in Angular, but I believe the challenge would like it defined this way:
var myApp = angular.module("foobar", []);
myApp.controller('coolCtrl', ['$scope', function($scope) {
}]);
Hamed Ali
5,626 Pointsthx Paul,
I used this and found that it worked also:
angular.module('foobar', []) .controller('coolCtrl', function($scope) {
});
Paul Jackson
7,585 PointsI like that style much more(most of my Angular stuff looks like that too). Glad it all worked!