Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am using angular treeview directive to show treeview. I am unable to render html.
for eg. B is showing as <b>B</b>.

here is the fiddle fiddle

i have used ng-html-bind for html rendering many times, but its not working here.

share|improve this question
    
What version of Angular JS are you using. In Angular 1.2.0 ng-bind-html-unsafe has been deprecated. – Vaibhav Jain May 22 '14 at 9:23
    
i am using v1.2.9 – devesh singhal May 22 '14 at 9:24
up vote 1 down vote accepted

As it looks in treeview's code, by default you can't.

But you can modify it's code (example for minified version), change

<span data-ng-class="node.selected" data-ng-click="'+a+'.selectNodeLabel(node)">{{node.'+e+'}}</span>

to

<span data-ng-class="node.selected" data-ng-click="'+a+'.selectNodeLabel(node)" ng-bind-html-unsafe="node.'+e+'">

Don't forget to add ngSanitize module to your app: https://docs.angularjs.org/api/ngSanitize

Upd: Here is updated fiddle http://jsfiddle.net/vL4TJ/76/

share|improve this answer

As ng-bind-html-unsafe has been deprecated now, you will need to use $sce.trustAsHtml. There is a nice article to understand what $sce is.

For quick reference you can also refer to stackoverflow question.

share|improve this answer
    
but how to use this with directive? ngmodules.org/modules/angular.treeview there is no option for using ng-bind-html-unsafe or any other – devesh singhal May 22 '14 at 10:35
    
There is angular version 1.0.6 used in fiddle. I don't think angular has $sce since that time. – gorpacrate May 22 '14 at 11:11
    
oops , @gorpacrate : Nice catch. I was trying to modifying the fiddle, but no avail. You mentioned the reason. Thanks. – Vaibhav Jain May 22 '14 at 11:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.