Get all updates of Java4s

Understanding of Angular’s $rootScope and $scope?

In this article I will describe the relation between Angular’s $rootScope and $scope and how they will work.

As I have explained in AngularJS Controller Example, $scope will work as a mediator between our view and controller for carrying the data in between them. One important point we need to remember here is, each controller will have one $scope object. But every Angular application can have only one $rootScope. The formula is very simple.

‘N’ no. of controllers in application = ‘N’ no. of $scope objects
One Angular Application = 1 $rootScope

Here it is..

Let me explain you with a simple example.


rootScope’s color: green
scope’s color (from controller): red


Have you observed, controller’s color variable does not overwrite the rootScope’s color value. Each scope has their own spaces, so there is no problem of overriding.  Very important point here is, rootScope’s content can be accessible across all the controllers (I have indicated this in the image).  That’s it friends, generally $rootScope will be useful if we would like to achieve the communication between controllers. I will explain more about it in the upcoming article.



2 Responses to “Understanding of Angular’s $rootScope and $scope?”
  1. himabindu says:

    Please upload the complete topics of AngularJs.Your way of teaching is nice.

  2. chetan says:

    Please Share ws and Angular js more tutorials


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Spring-Boot-tutorials Hibernate tutorials Spring tutorials Struts tutorials Servlets tutorials Ajax tutorials Log4j tutorials jQuery tutorials Json tutorials Core Java tutorials Web Services tutorials AngularJs tutorials
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2017 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.