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 trial

JavaScript AngularJS Basics (1.x) Controllers and Scope Creating controllers in Angular

Ila Gupta
Ila Gupta
5,147 Points

In the body of the "coolController" callback function

In the body of the "coolController" callback function, attach a variable to $scope called someNumber with a value between 1 and 5.

if someone knows the answer?

My code:

angular.module ('foobar', [])

.controller ('coolCtrl' , function($scope)

        {
              $scope.coolController = function()
              {               
                $scope.someNumber = '4';
              };
         });

I guess I am confused with the question.

Samuel Gates
Samuel Gates
1,181 Points

yeah, it confused me as well. you need to drop $scope.coolController entirely. also, i don't think you number should be a string (remove the quotes from '4').

Ila Gupta
Ila Gupta
5,147 Points

I removed it as string but do not get it by dropping $scope entirely. Could you elaborate? thanks!!

Samuel Gates
Samuel Gates
1,181 Points

.controller('coolCtrl', function ($scope) { $scope.someNumber = 4; });

works. if not, you probably have an errant semi-colon or something.

Ila Gupta
Ila Gupta
5,147 Points

Thanks this worked out. Sometimes the questions puzzle you up.

2 Answers

angular.module('foobar', [])

.controller("coolCtrl", function($scope){
  $scope.someNumber = 4;
});

I solved it after 26 hours with help of Ken's hints.

Ila Gupta
Ila Gupta
5,147 Points

Well..this is the answer!!