Reputation: 337
I have the following directive
...
template: <div ng-include={{model.template}} \>
...
Where the template is dynamic. I would like to inject additional HTML inside that template via in the directive link or compile phase. How do I go about doing so?
Upvotes: 0
Views: 868
Reputation: 4237
Use a function to return the template as a string:
function resolveTemplate(tElement, tAttrs) { } angular.module('MyApp').directive('maybeLink', function() { return { //... template: resolveTemplate, //... }; });
see this answer for more details: https://stackoverflow.com/a/21105774/149060
Upvotes: 1