Interviews2 answers
Explain what is the difference between link and compile in angular.js?
2 Answers
Compile: traverse the DOM and collect all of the directives. The result is a linking function.
Link: combine the directives with a scope and produce a live view. Any changes in the scope model are reflected in the view, and any user interactions with the view are reflected in the scope model. Making the scope model a single source of truth.
Bhuvanesh MohankumarPosted May 19, 2016, 5:18 AM EDT
Compile function: It is used for template DOM Manipulation and collect all of the directives.
Link function: It is used for registering DOM listeners as well as instance DOM manipulation. It is executed once the template has been cloned.
Nitin ChoudharyPosted Jan 20, 2015, 2:42 AM EST

