-1

I have this code in my Template HTML

    <div *ngIf="alertOptions?.texts">
      <p *ngFor="let paragraph of alertOptions?.texts">
        {{ paragraph }}
      </p>
    </div>
    

The Texts in my JSON are like:

Please <b>Call us</b> <a href="tel:+5798643210"> 5798643210</a>.<br>Weekends Chat with us <a href="#">Chat</a>

I Know that I need to escape the quotes in my JSON!

"alertOptions":{
    "texts": [
      "Please <b>Call us</b> <a href=\"tel:+5798643210\"> 5798643210</a>.<br>Weekends Chat with us <a href=\"#\">Chat</a>"
    ]
}

But, I getenter image description here

How to do that?

  • Does this answer your question? [Angular HTML binding](https://stackoverflow.com/questions/31548311/angular-html-binding) – R. Richards Jan 25 '22 at 19:48
  • Hello, in JS you don't need the escape quote if you use [template litterals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) – dolig Jan 25 '22 at 21:26
  • check this https://stackoverflow.com/questions/36265026/angular-2-innerhtml-styling – joseluisbz Jan 29 '22 at 04:33

1 Answers1

2

Please try <div [innerHTML]="paragraph" > </div>

Random
  • 3,158
  • 1
  • 15
  • 25
Mateusz Ścigała
  • 186
  • 1
  • 1
  • 5