How would you programatically change or adapt the template of a directive before it is executed and transformed?

Technology CommunityCategory: AngularJSHow would you programatically change or adapt the template of a directive before it is executed and transformed?
VietMX Staff asked 3 years ago

We should use the compile function. The compile function gives access to the directive’s template before transclusion occurs and templates are transformed, so changes can safely be made to DOM elements. This is very useful for cases where the DOM needs to be constructed based on runtime directive parameters.