3

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?

0

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.