Notes to self & advice to those working in Angular 1.x Land. If you don’t want to read this, here are three elevator pitch points to consider when understanding directives:
- Use the
compilefunction to change the original DOM (template element) before AngularJS creates an instance of it and before a scope is created. - Use the
pre-linkfunction to implement logic that runs when AngularJS has already compiled the child elements, but before any of the child element’spost-linkfunctions have been called. - Use the
post-linkfunction to execute logic, knowing that all child elements have been compiled and allpre-linkandpost-linkfunctions of child elements have been executed.
I disavow any credit for the three points above. @jvandemo wrote the clear and excellent piece above. This is just my summary of his summary on the article which you ignored if you are reading this far :-) This post is mainly for a reference at my fingertips later on in the future when I need to real it.