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
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
Share asked Aug 23, 2018 at 14:56 physicsboyphysicsboy 6,38822 gold badges77 silver badges139 bronze badges 01 Answer
Reset to default 6You 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.