How to force attribute directive to wait for element directive to evaluate?

I have two custom directives define in my project:

  • <include-partial> - element directive which gets template via $http service, compiles it and inserts into DOM
  • on-show="someFn()" - attribute directive, which should call some function when the element becomes visible

I'd like to combine the two, so that I could write code like this:

<include-partial on-show="init()">

This, however won't work, as the content of <include-partial> is fetched asynchronously, so on-show has no DOM to attach to.

Do you have any ideas how to tackle this? How could I force on-show to wait until the <include-partial> is done compiling the DOM?

Thx in advance!

In your case "on-show" is never trigger because "include-aprtial" tag don't changes it's visibility. Try to hide "include-partial" in link function and show on content load.