Reputation: 621
I can't find the meaning of the first $scope in this example:
app.controller('HelloController', function($scope) {
$scope.message = 'Hello World!';
});
I know that this is JavaScript and it is supposed to be a parameter for the function but I don't understand what sort of parameter it sets.
Can anyone help?
Thanks!
Upvotes: 0
Views: 57
Reputation: 1399
A $scope
is a JavaScript object which is used to communicate between controller and view. Basically, $scope binds a view (DOM element) to the model and functions defined in a controller.
see more at https://docs.angularjs.org/guide/scope
Upvotes: 2
Reputation: 1436
The $scope parameter is being injected into your controller and acts as the "glue" between your controller and view. So, in your example you would be able to referrence the $scope.message property from your html like this:
<div ng-controller="HelloController">
{{message}}
</div>
I would check out the docs and Angular communities on google+. Good resources to get started.
Upvotes: 3