Reputation: 1914
I have a 'helper' directive that allows me to easily access child DOM elements within the parent directive. However, I'm running into an issue when I'm using this helper directive in conjunction with another directive. If I use a template
in the directive, everything works fine. However, if i use a templateUrl
i get an error saying the element the helper directive saves to scope is undefined.
A little hard to explain, but here's the plunkr: http://plnkr.co/edit/NHKBGfro7Xe3dSalq5bt?p=preview
NOTE: that i've added a setTimeout that fires after 5 seconds, which allows the templateUrl
directive to work, since it's now available on the scope of the parent directive.
Upvotes: 1
Views: 112
Reputation: 9227
This is expected behavior.
Post-linking function Executed after the child elements are linked.
Note that child elements that contain templateUrl directives will not have been compiled and linked since they are waiting for their template to load asynchronously and their own compilation and linking has been suspended until that occurs.
It is safe to do DOM transformation in the post-linking function on elements that are not waiting for their async templates to be resolved.
Upvotes: 4