Get all updates of Java4s
Follow Us: Email Newsletter

Understanding of Angular’s $rootScope and $scope?

AngularJs » On Aug 4, 2016 { 1 Comment } By Sivateja

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.


  ♦ About Author ♦

Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.


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

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


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

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