Angular directives can be a black hole of thoughts, and one of those being, “where do I put code, in ‘controller’ or ‘link’?” The short short answer: ‘link’. The longer short answer: Ask yourself “when do I want my code to run?
* Before compilation? – Controller
* After compilation? – Link
What does this mean? While I would never condone putting DOM manipulation in an angular controller, I see it constantly, and its important to know what is actually going on and when functions are run
Your new post is loading...