AngularJs is very good template engine, handles Document object model (DOM) more efficiently. In this post iam going to explain how to communicate with multiple controller in angularjs using angular factory. If you want to learn some basics of angularjs you follow this link. If you have good knowledge of Javascript and jQuery then angular is relay easy for you. This post is really very easy to understand.

 

Live Demo

In angular communication between pages is done with help of controller and data sharing between controller is done by three way

  1. Factory: Object is created inside the factory and return it .
  2. Service: With the service, you just have a standard function that uses the this keyword to define function.
  3. Provider: With the provider, there’s a $get you define and it can be used to get the object that returns the data.

Sample Code

In this sample i am to create a simple angular script which contain three controller and first controller have a value which is increased +1 and +2 by other two controller. Here is a code

to check this code working please click on demo link above. This is a simple example to learn how to communicate between different controller in angular js.