The ng-bind-html Directive is used to bind the innerHTML of an HTML element to application data and remove dangerous code from the HTML string. $sanitize service is a must for ng-bind-html directive. It is supported by all HTML elements.
<element ng-bind-html="expression"> Contents... </element>
- Initialize the libraries that we are using. Here, we are mainly use angular-sanitize.js library.
- Create app and its controller scope.
- Define the contoller variable.
- Call the app and controller to body of html.
- Inside the body use span tag and use attribute ng-bind-html and assign the value as the scope variable.