I have nested controllers and need to astablish communication between the controllers.There are two ways I can think of achieving this:
- Have a central "PubSub" service that all the controllers can use to communicate. The disadvantage of this in my opition is that each controller can talk to any other controller and there is no meaning to the heirarchy.
- Another approach is that controller can only talk to his father and this children, as described is the image:
So I need a separate communication channel for each heirarchy level. Not sure how to achieve this. I thought of making a service that provides a communication channel but how do I inject it to the relevant controllers??
Which solution is better and how do I implement the second solution is it's better? or maybe there are other solutions?