Reputation: 55729
I have a directive with an isolate scope being rendered inside the template of an outer directive.
I want to send a notification message to the child directive to have it cancel a timer. How can I do this idiomatically?
Will scope.$broadcast
do this for me even though the child scope is isolate?
Upvotes: 3
Views: 52
Reputation: 193261
From documentation for scope.$broadcast:
Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners.
So it will perfectly work in your case. Note, that despite of being isolated the scope of the inner directive is still child scope of the outer. Isolated just means that this scope doesn't inherit prototypically, however its $parent
points to the real parent scope. so $broadcast will work in this case of course.
Here is a little example I set up to test it:
Demo: http://plnkr.co/edit/OoUqgV8oRofakXVf2OZv?p=preview
Upvotes: 2