Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS : Render HTML in $scope variable in view [duplicate]

Tags:

angularjs

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?

like image 497
Fraser Avatar asked May 08 '14 16:05

Fraser


1 Answers

It should be

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

and

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

Also see this, AngularJS : Insert HTML into view

like image 137
user1415567 Avatar answered Sep 29 '22 13:09

user1415567