0

I have started practicing the basics of Angular.js and was trying some code doing data binding and controllers, and get the error at following code:

http://jsfiddle.net/yy9wM/

$scope.$watch('funding.startingEstimate', computeNeeded);

The error I get in browser console is ReferenceError: $scope is not defined. I have read the related questions to this but didn't help

2 Answers 2

1

The problem here is your app isn't even running. jsfiddle can be tricky to with angular.

Here is what it looks like you were trying to do: http://jsfiddle.net/yy9wM/1/

Angular will now bootstrap itself, and be wrapped in the head.

$scope is passed into you controller function CalcController it is not defined outside of that. It represents the scope of that controller, so any properties defined on that scope are available with in the controller just like {{needed}}.

I'd suggest following a tutorial or revisiting some javascript basics as your code shows little understanding of javascript principals.

Good luck.

Sign up to request clarification or add additional context in comments.

3 Comments

I prefer jsbin to jsfiddle myself.
@Matthew.Lothian yes I am trying to learn Angular and also new to javscript,thank you for the advice,would revise that and get it done
@Mike Cheel Thank you for the suggestion,I did also find jsbin more preferable than jsfiddle.
0

JSFiddle can be a funky when it comes to loading Angular. You also had $scope.watch defined outside of your controller.

Here is a working example: http://plnkr.co/edit/EgTH6OThy8or3rPpi0a7?p=preview

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.