$scope
(which is a child of the root scope) is maintained by every view, so if any one view controller is assigned a $scope
variable remains invisible to other controllers when all variables are present.
The $scope
object connects controller with view to execute the expressions context and model the accessible data to be displayed in the view page. If a variable possess the same name in both the current scope and rootScope, the application uses the one in the current scope. $scope
object is used by two controllers, but, $scope
object is different for each controller. The two controller functions for the views are assigned various values for the data.theVar
variable in each $scope
object.
Output: