1

I am trying to bold some words in a string, for example, I want the name variable to be bold. In my Angular component, my code is like this:

const name = 'Mike';
const message = `My name is ${name}.`

And I'm adding < b > tag to the string:

const message = `My name is <b>${name}</b>.`

But in my angular template, as I'm passing the message along, it did not bold the string. Instead, it shows 'My name is < b >Mike< /b >.' in UI.

<div>{{message}}</div>

I tried to encode the bracket but id didn't work; Are there any way that I can make it partial bold?

1
  • ##here is another page for you to look at.## ======= They give the answer here Commented Jun 26, 2019 at 21:25

1 Answer 1

2

I think you probably need to use innerHTML:

<div [innerHtml]="message"></div>

You can check the documentation for more information

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.