Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  131] [ 7]  / answers: 1 / hits: 18097  / 11 Years ago, wed, april 17, 2013, 12:00:00

What is the order of execution of directive functions? The documentation doesn't seem to address this.


Ex



  1. template / templateUrl (is evaluated)

  2. controllerFn

  3. compileFn

  4. linkFn


Answer


From answer below: http://plnkr.co/edit/79iyKSbfxgkzk2Pivuak (plunker shows nested and sibling directives)



  1. Template is parsed

  2. compile() (changes made to the template within compile are proliferated down to linking functions)

  3. controller()

  4. preLink()

  5. postLink()


More From » angularjs

 Answers
14

Pre-linking function: Executed before the child elements are linked.
Not safe to do DOM transformation since the compiler linking function
will fail to locate the correct elements for linking.



Post-linking function: Executed after the child elements are linked. It
is safe to do DOM transformation in the post-linking function.




Above excerpt is taken from the official docs on directives.



So, to answer your question, Post-linking/Link function is when/where you can safely operate on element.children().


[#78823] Wednesday, April 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylanalis

Total Points: 438
Total Questions: 85
Total Answers: 102

Location: Barbados
Member since Sun, Nov 27, 2022
1 Year ago
kylanalis questions
Sat, Oct 2, 21, 00:00, 3 Years ago
Tue, Oct 13, 20, 00:00, 4 Years ago
Thu, Feb 13, 20, 00:00, 4 Years ago
Tue, Jan 7, 20, 00:00, 4 Years ago
;