2
votes

In my directive, I'd like to set the html of the element based on a template url:

element.html('some url to a template html file');

instead of

element.html('<div>test</div>').show(); 

how can I do that ?

EDIT

I do not wish to use templateUrl because the template must be dynamic. The template will change according to a scope variable set on the directive. Sorry if I haven't made myself clear before.

1
How about using templateUrl: url in the directive - tymeJV
What do you mean by "the template must be dynamic" ? Does that mean that you will have different html templates and you need to dynamically select which one to display, or that the actual HTML markup in the template will change based on some scope variable? - kmdsax
first scenario. I will have different html templates and based on a value passed to the directive, the template will change. - Sam

1 Answers

1
votes

I suppose if you really want to do this you will have to use the $compile service. Maybe try to take a look at this answer.