I have a variable in a scope with some HTML content. I want to render it as HTML on the webpage, but in my case it displays as full text. Can anyone help me?
This is my code:-
//contoller.js
$scope.message = '<b><i>result has been saved successfully.</i></b>';
//demo.html
<p ng-bind="message"></p>
You need to inject $sce
service into your controller
or Directive
etc. and use $sce service
like this:-
$scope.Message = $sce.trustAsHtml("<b><i>result has been saved successfully.</i></b>");
And bind this in your HTML page e.g;
<p ng-bind-html = "Message"></p>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments