Is there any way in which I can make part of a string being assigned to a variable bold?
I have tried the following:
boldTxt = 'bold'
message = 'this text should be ' + this.boldTxt.toUpperCase().bold() ;
But what I get in the HTML is:
this should be <b>BOLD</b>
STACKBLITZ
You can use innerHTML, something like:
<p [innerHTML]="message"></p>
Setting the value of innerHTML removes all the element's contents and replaces them with nodes constructed by parsing the
HTML set in the message variable.
When the text is set using statement <p>{{message}}</p> the content is not parsed as HTML but as plain string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With