21

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
  • 45,213
  • 22
  • 199
  • 169
Fraser
  • 14,036
  • 22
  • 73
  • 118

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