2

In controller bind same data like $scope.name = "<div>geetha teko</div>", this name will now binded to html like {{name}}, it is printing like this in browser."<div>geetha tek0</div>", how can get only 'geetha tek0' in browser with html tags.

I tried bellow please help any one.

html code

<div>
    <p> my name is: {{name}}</p>
</div>

angularjs

<script>
   function MyCtrl($scope) {
       $scope.html = "<div> ramesh bogandla</div>"
   }
</script>

you can check on jsfiddle:http://jsfiddle.net/ADukg/10127/

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
geetha tek
  • 21
  • 4
  • looks like : http://stackoverflow.com/questions/18157305/compiling-dynamic-html-strings-from-database – moks Feb 15 '17 at 12:43

1 Answers1

0

I updated your JSFiddle, http://jsfiddle.net/ADukg/10129/.

Use the following:

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

Or for what you have in your question rather than the JSFiddle you provided:

<p> my name is: <span ng-bind-html-unsafe="html"></span></p>

Here's some further information that might be handy.

Community
  • 1
  • 1
Tim Harker
  • 2,367
  • 1
  • 15
  • 28