2/20/2015 ~ 1 min read

1.x Directives


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:

  1. Use the compile function to change the original DOM (template element) before AngularJS creates an instance of it and before a scope is created.
  2. Use the pre-link function to implement logic that runs when AngularJS has already compiled the child elements, but before any of the child element’s post-link functions have been called.
  3. Use the post-link function to execute logic, knowing that all child elements have been compiled and all pre-link and post-link functions 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.


Headshot of Matthew Hippely

Hi, I’m Matthew. I live in Ventura County, and spend my time thinking about systems, software, and how things evolve over time.

You can find me on GitHub, LinkedIn, or read more about me here.