0

I have a html value inside my scope, i need to append it inside a div, how do i do that?

Example:

$scope.htmlValue = '<p> text text <\p>'; 

Html : 

<div> {{ htmlValue }} <\div> 

Thanks !!

Alimon Karim
  • 4,354
  • 10
  • 43
  • 68
Ran Sasportas
  • 2,256
  • 1
  • 14
  • 21

2 Answers2

0

You are not using AngularJS correctly. If you need to modify the HTML, you should probably be in a directive.

That being said, you need to tell angular ahead of time what can be trusted as html and then you can use the ng-bind-html directive to bind to html. You will need to use $sce.trustAsHtml(). Related post.

Community
  • 1
  • 1
Joel Jeske
  • 1,618
  • 14
  • 17
0

What you probably need is $sanitize service. take a look here https://docs.angularjs.org/api/ngSanitize/service/$sanitize

However, as has been already meantioned, it is very likely you are not using angularJS in expected way.

Mirek Surma
  • 148
  • 1
  • 10