1

I am trying to create a directive this way -

scope.nodeTemplate = '{{node.nodeText}}'; 

Part of template

'<ul>' + '<li class="tree-node" data-ng-repeat="node in nodes">' + '<span>' + scope.nodeTemplate + '</span>' + '</li>' + '</ul>' 

Based on some condition I would like to change the nodeTemplate and it can be an html string like -

'<input type="text"/>' 

But the issue is when it try to do this thing angular does not render the html. It simply puts the html string. I am kind of stuck here. Can someone suggest some solution?

1

1 Answer 1

2

You need to use ng-bind-html-unsafe like:

'<span ng-bind-html-unsafe="nodeTemplate"></span>' 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.