0

I have a model in angular view. I am passing String to the model from the controller as

<b>myName</b>

hoping it to be displayed in bold, but I am not getting the desired result. Instead its getting displayed as a string as it is. Why is it so,and what is the fix? I thought angular directive compile would help, but no help.

Matthew Green
  • 10,161
  • 4
  • 36
  • 54
Shadab
  • 367
  • 3
  • 26

2 Answers2

0

Instead of passing string to models in scope directly, you should use sce.trustAsHtml

$scope.bindHTML = $sce.trustAsHtml("<b>myName</b>");

Then in your view template, use ng-bind-html to handle html binding.

<div ng-bind-html="bindHTML"></div>
Rebornix
  • 5,272
  • 1
  • 23
  • 26
0

Not being able to see your code it's hard to say exactly what's going on but my guess is you probably need to the model using ngBindHtml. If your model has an html string in it then that's usually the way to go.

ragamufin
  • 4,113
  • 30
  • 32