Reputation: 13476
So I have two directives splitter
and pane
that may be used like so:
<splitter>
<pane></pane>
<pane></pane>
</splitter>
<splitter>
</splitter>
I want them all to have isolate or inherited scope. However I also want to be able to $broadcast
(or equivalent) between them so that if I were to $broadcast
on one directive's scope, the same event would be triggered on all the nested directives that are listening but not it's parent or siblings (no $rootScope
here).
How would one go about doing this? My solution must be future friendly as I will be adding more directives in to the mix which also listen for this event.
Upvotes: 2
Views: 1573
Reputation: 572
To do inter-directive communication, the best is to use the parent directive controller and expose methods in this
.
Then you just have to require it in your children directive (require: '^splitter'
) and the parent controller will be injected as the fourth argument of your link
function.
For more information, you can see the official documentation about Creating Directives that Communicate.
Upvotes: 3