AngularJS Scope
Scope is binding part between the View(HTML) and the Controller (JavaScript).
Scope is object with the available properties and methods.
Scope is always available for both the view and controller.
Use of Scope?
When we make controller in ANgularJS we will pass the $scope object as an argument. Below example will helps you to undersatnd the properties made in controller and can be referred in the view:-
In above screen we add properties to the $scope object in the controller, and the view gets access to these properties. In the view we cannot use the prefix $scope.
Uses Of Scope?
IF below 3 points comes in AngularJS application then scope comes into picture:-
(1)View which is the HTML
(2)Model which is the data available for the current view
(3)Controller which is the JavaScript function that changes, makes removes and controls the data
If above 3 points comes into picture then scope is the model.
Here scope is a JavaScript object with properties and methods which is available for both the view and the controller.
| |