As a newcomer to Javascript, I recently finished reading the book Eloquent Javascript and am now delving into AngularJS from O'Reilly. While working on a code snippet provided in the AngularJS book, I encountered hours of frustration trying to figure out why it wasn't functioning as expected. It turned out that the only difference between the book's code and mine was the absence of the '$' sign before "scope" in the TextController function. Once I added the '$' back in, everything worked smoothly.
I initially thought I could omit the '$' because 'scope' is just a local variable within the function. In other programming languages like Java or C++, you can name parameters freely since they are passed by value anyway. Could someone kindly correct my misconception and explain the necessity of naming the parameter "$scope?"
<!doctype html>
<html ng-app>
<body ng-controller="TextController">
<p>{{someText}}</p>
<script src="angular.min.js"></script>
<script>
function TextController($scope) {
$scope.someText = 'You have started your journey.';
}
</script>
</body>
</html>