I have a page with a number of directives. The screen controller searches the DOM and update the class of the first directive it finds. The code works as expected when I use template but fails without a warning or error when I use templateUrl. I suspect there is a race condition since the templateUrl is loaded but cannot find a way to ensure in the controller the DOM is ready to update.
I've also read that a controller should not change the DOM but in my case I'm writing a keyboard navigation method that needs to search all the directives to update navigation focus. This code could be injected into the directive but that still leaves the directive searching the entire DOM rather than just the element it owns.
bodyelement. In any case you are attaching key press events to one of your elements, which is probablybody. - Denis Pshenov