The $scope in an AngularJS is a built-in object, which contains application data and methods. The $scope objects that refer to the model. The $scope is the application View Mode, they act as a glue between controller and view. It is located between them and s used to exchange information related to the model.
When we create a controller, Angular does it’s magic and creates a $scope object for that controller. This is sometimes referred to as the local scope.
The model is typically stored within the controller’s scope object, and the controller communicates with the view.
The $scope parameter model is passed to the controller function.
Example of scope
would allow the local scope to be accessible via the $scope parameter.
In example 2 below we are define student object as
Accessing student object in View and we can use ng-repeat directive
The AngularJS creates and injects a different $scope object to each controller in an application. So, the data and methods attached to $scope inside one controller cannot be accessed in another controller.
Sharing data between controller, If data define at root scope, then we data is accessible to any controller. We can’t define one controller within other, we can use a different approach to achieve nested controller.