Consider two nested directives with isolate scopes:
<dctv1>
<dctv2></dctv2>
<dctv1>
If I want dctv2 to talk to dctv1 I have may options:
- I may require the controller of
dctv1in the definition ofdctv2using therequire:'^dctv1' - I may call an expression on the parent scope with the wrapper
<dctv2 callParent="hello()"></dctv2>andscope:{callParent:'&'} - I can also use
$scope.$emitindctv2but then all parent scopes will hear the message.
Now I want dctv1 to talk to dctv2.
- The only way I may accomplish this is to use
$scope.$broadcast, but then all children will hear.
By talk to here i mean call a function or similar. Don't want to set up watches clogging the digestloop.
How can I make dctv1 notify dctv2 in the best way, making them loose-coupled? I should just be able to remove dctv2 without errors.