Reputation: 26216
I want to reuse directive template. How could I get an access to it inside a link function?
I expect something like
this.template
Upvotes: 0
Views: 125
Reputation: 6899
I'm not sure this is possible, but you can make the template a function. For example you can have a templateUrl that is a function and returns different templates. eg
templateUrl: function(element,attr){
if (attr.type == 'select'){
return 'views/select.html
} else {
return 'views/standard.html
}
},
Its a basic example, but gets the idea across. What do you need the template in the link function for?
Upvotes: 0
Reputation: 1506
You must use template cache service.
$templateCache.get('path/to/template/my.html')
http://docs.angularjs.org/api/ng/service/$templateCache
Upvotes: 2