Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ho do I show curly brackets symbol as text in Angular?

Is there a simple way to show curly brackets symbol in Angular?
like following:

<div>{{hello curly brackets symbol}}</div>

I can use innerText to solve this issue. but maybe have another better way to do.

<div [innerText]="'{{hello curly brackets symbol}}'"></div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, your approach using [innerText] is one way to display curly brackets as text in Angular templates. Another approach is to use the HTML entity for curly brackets, which is { for { and } for }. Here’s how you can use it:

{{ ‘{’ }}hello curly brackets symbol{{ ‘}’ }}

This will render as:

{hello curly brackets symbol}

Using HTML entities can be useful if you have many instances of curly brackets you need to display as text and want to avoid using [innerText] repeatedly.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading