javascript - Race conditions on directives -
i have directive calculates height , distance top of window of element passed in id attribute. issue i'm running have several of these directives running (on elements attached same directive), , i'm running race condition of directives lower down in dom running before ones higher whatever reason.
is there way can make bottom ones wait ones higher via promise or something? if so, how implement that? there better way of handling this?
if want code executed directive in descending order (higer in dom comes first), should either put code in directive's controller
, or prelink
methods.
the default link
method shortcut postlink
executed in ascending order.
that being said, don't know code making guess, sounds service more appropriate directive, unless calcul you're doing done directly in directive element, in case using $element
should enough. should not pass id
or selector directive.
Comments
Post a Comment