Communication Between Sibling Directives

Directives are powerful for encapsulating code and doing neat things with your HTML, but they can present difficulties when they need to share information. A study of isolate scope will reveal much about how directives talk to their parent, but talking between siblings is a different issue that is rather independent of the scope of the directive.

I ran into this while making a directive for column headers. I wanted each column title to update the sorting of the table when clicked. The problem was that the value of which column was sorted needed to be “shared” by all the directives. The especially difficult part was getting the directives to see changes to the master value.

Here is my solution in JSFiddle…

Read More