20

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?

John Slegers
  • 41,615
  • 22
  • 193
  • 161
Fraser
  • 13,496
  • 22
  • 71
  • 116

1 Answers1

33

It should be

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

and

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

Also see this, AngularJS : Insert HTML into view

Community
  • 1
  • 1
user1415567
  • 431
  • 5
  • 14