Home > Software engineering >  Angular binding with escape characters
Angular binding with escape characters

Time:01-15

I want to display a string value that treats escape characters for what they are. But through default binding these characters just cleared. Setting string value as innerText does what I want but I hope there's more convenient way to do it. Do you know any?

Demo https://stackblitz.com/edit/angular-ivy-xuzfwc

CodePudding user response:

<p [innerText]="testText"></p>

Still inner text, but cleaner.

CodePudding user response:

Inner text in template, as @Yuriy suggested, or:

<pre>{{ testText }}</pre>
  •  Tags:  
  • Related