There are many different ways to achieve this.
- Using $ rootScope.
- Using Services
- Use broadcast and emit
- Declare an object in the parent controller, and then modify the same object in the child controller.
Using $ rootScope is not a good approach, since the $ rootScope variable is destroyed when the application is closed.
I will also not recommend broadCast or emit until it is needed.
Services are good for b / w communication controllers, but again you enter them and change the methods.
In your scenario, I would recommend using a common $ scope object variable, which is declared inside the parent and used in child controllers, since all methods are inherited in child controllers.
Ritesh
source share