How to Share Data Between AngularJS Controllers

There are several ways to share data between AngularJS controllers:

1) Use AngularJS $rootScope without creating Service

2) Use depending parent and child relation between controller scopes.

3) Use AS keyword (If you are using angularJS 2.0, then you can use the “As” keyword which will pass your data from one controller to another controller)

Use AngularJS $rootScope without creating Service

AngularJS $rootScope is another option to share data between two controllers. This is also a way to share data across Controllers, to read or modify a global property.

See bellow example:

HTML Code:

Use Depending Parent And Child Relation

As the name suggest this mechanism works with two controllers.

See bellow example:

HTML Code:

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

Article Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Solved Programs