Link is used for combining the directives with a scope and producing a live view. The link function is used for registering DOM listeners as well as updating the DOM. The linking function is executed as soon as the template is cloned.
There are two types of linking function:
- Pre linking function
Pre-linking functions are executed before the child elements are linked. This method is not considered as a safe way for DOM transformation. - Post linking function
Post-linking functions are executed after the child elements are linked. This method is a safe way for DOM transformation.