0

I have a string of text that I need to format so it displays properly to the user. Right now, the specific phrase I want to format (a variable) is surrounded by single quotes. That doesn't look pretty. I want to add a <strong> tag or <h4> tag around the phrase before delivering it to another component which will display it.

Component 1: (Typescript)

this.persistingData.changeConfirmationDescription(`Are you sure you want to add the school '${this.schoolName}'?`);

Component 2: (HTML)

<h2>Confirm Action:</h2>
{{confirmationDescription}}
<button> Cancel </button> <button> Confirm </button>
1
  • I got confused with your question especially here - I want to add a tag or tag. Could you please add the desired result you actually want and what you are currently getting? Commented Oct 14, 2020 at 20:21

1 Answer 1

2

If you need to insert some HTML into the string then do this:

this.persistingData.changeConfirmationDescription(`Are you sure you want to add the school <strong>${this.schoolName}</strong>?`);

And then in *.html:

<h2>Confirm Action:</h2>
<div [innerHtml]="confirmationDescription"></div>
<button> Cancel </button> <button> Confirm </button>
Sign up to request clarification or add additional context in comments.

1 Comment

Nice! That did it!

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.