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

This question already has an answer here:

I have a $scope variable like so:

$scope.example = "<h1>Hello</h1>"

When I output this in my view {{example}}, I want the HTML rendered. At the moment it outputs:

<h1>Hello</h1>

rather than

Hello

Is what I am trying to achieve possible?

share|improve this question

marked as duplicate by Elliott Frisch, EdChum, Jay Blanchard, Zach Saucier, sgress454 May 8 '14 at 22:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

It should be

$scope.html = "<h1>Hello</h1>";

and

<div ng-bind-html-unsafe="html"></div>

Also see this, Insert HTML into view using AngularJS

share|improve this answer
1  
It is nice that you don't do the DOM manipulation like this but the above was answer to the question being asked. – user1415567 May 9 '14 at 15:15
2  
You shouldn't put kerosene in your gas tank either but nothing is stopping you. If you want to do Angular you should do it correctly. Junk code leads to junk products. – mortsahl May 9 '14 at 16:37
1  
What if you get a HTML-formatted blog article from a remote server where you cannot predefine any scopes? for me this solution worked: <p ng-bind-html="article.body"></p> – redestructa Jul 7 at 11:07
    
@redestructa spot on. – Nathan Jul 19 at 8:07

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