0

I ran across this in a book called ng-book by Ari Lerner.

"The compile option by itself is not explicitly used very often; however, the link function is used very often."

Also, I refer this page but still this confuse me (Difference between the 'controller', 'link' and 'compile' functions when defining a directive)

Can someone justify this a little bit further?

Community
  • 1
  • 1
geckob
  • 7,680
  • 5
  • 30
  • 39
  • That SO link contains a good answer. What exactly are you confused in-regards-to that isn't detailed there? – mccainz Oct 16 '14 at 18:37
  • @mccainz It is very good. But it does not justify the quote I quoted from the book. Just wondering why is it true? – geckob Oct 16 '14 at 19:01

1 Answers1

0

Keep in mind that compile is used to return the linking function that allows the template to be bound to the scope. The cases where you need to interject yourself into this process are mainly limited to the need to actually manipulate the template prior to that binding. One example would be to modify the template based on the attributes set by the user. In short most developers forget about compile unless they need to modify the template. 'Most' are more concerned with the instance of their directive and what to do with the scope bound to that instance (domain of the linking function).

I am using 'Most' very loosely as I have absolutely no data regarding this.

mccainz
  • 3,478
  • 5
  • 35
  • 45