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

AngularJS code:

$scope.checking="<div style="color:red;">check</div>";

HTML code:

<p ng-bind-html="checking"></p>

so i used $sanitize for this one and the ng-bind-html directive to get the job done.

So the result in html page is:

check

and the above should come in red color

i got the output but the string 'check' does not come in red! the style tag is ignored! how can i do it? do i use interpolate?

Any way to do it? hopefully its simple... AngularJS experts please help!

share|improve this question

$sanitize Sanitizes an html string by stripping all potentially dangerous tokens.

So do use $sce service method to make it trusted html using trustAsHtml method.

$scope.checking= $sce.trustAsHtml("<div style="color:red;">check</div>");

share|improve this answer
    

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.