AngularJS event propagation--siblings?

core picture core · Sep 5, 2014 · Viewed 7.9k times · Source

I understand that $emit sends messages up the DOM tree, and $broadcast sends messages down.

What about sending messages between sibling DOM elements—how do I do that?

Answer

Mathew Berg picture Mathew Berg · Sep 5, 2014

It does not send it up the DOM tree. It sends it up the scope tree, so there's no concept of sibling DOM elements when dealing with scopes. What you can do with $emit though is $emit it up to the parent, stop the propagation and then broadcast which all the siblings will pick up (as well as their children)