In Angularjs, when you want to render the background text with HTML tags, use ng-bind-html instead of ng-bind, you can normally use the HTML tag you want to use. Note, however, that if you use a symbol in the text, be aware that you want to escape the symbol.
Examples of the use of 1>ng-bind-html:
index.html
<div ng-controller= "Examplecontroller" >
<p ng-bind-html= "myhtml" ></p>
</div>
Protractor.js
It (' Should check ng-bind-html ', function () {
expect (element (by.binding (' myhtml ')). GetText ()). Tobe (
' I am an ' Htmlstring with links! and other stuff ');
script.js
Angular.module (' bindhtmlexample ', [' ngsanitize '])
. Controller (' Examplecontroller ', [' $scope ', function ($scope {
$scope. myhtml =
' I am ' <code>html</code>string with ' +
' <a href= ' # ' >links!</a > and other <em>stuff</em> ';
}];
Result: <a href= "#" >links!</a> and other <em>stuff</em> were parsed
Effect Chart:
But note that if you use the symbol in the text, note that you want to escape the symbol
such as: (1) greater than symbol (>)---> >
(2) less than sign (<)---> <
Otherwise system error: