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?

Hossain Muctadir
  • 3,546
  • 1
  • 19
  • 33
  • this can help you: http://stackoverflow.com/questions/9381926/insert-html-into-view-using-angularjs?answertab=votes#tab-top – lu cip Oct 09 '13 at 10:48

1 Answers1

2

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

'<span ng-bind-html-unsafe="nodeTemplate"></span>'
Attila Miklosi
  • 718
  • 4
  • 4