0

I'm creating a front end application which looks at a database of Hearthstone cards allowing you to sort and search them. However, the Text displayed on the cards (Within the database) has HTML formatting within it such as <b> </b>

EG: The card "Toxic Arrow" has a text field containing:

Deal $2 damage to a minion. If it survives, give it <b>Poisonous</b>.

currently the rendering function looks as follows:

 `<tr *ngFor = "let card of cards">
     <td> {{card.text}} </td>
     <td> <img [src] = 'card.img'
         [title] = 'card.name'
         [style.width.px] = ImageWidth> </td>
  </tr> `

and currently the output within the table shows this: Deal $2 damage to a minion. If it survives, give it <b>Poisonous</b>.

I'm looking for a way to format this text quickly inside this loop to remove the $ and use the already existing HTML <b> tag

I'm not using the older AngularJs, I'm using the most current up to date version of Angular.

dmcgrandle
  • 5,934
  • 1
  • 19
  • 38

1 Answers1

3

You can replace the first <td> in your code with <td [innerHTML]="card.text"> </td>. This will cause the text to be displayed with HTML formatting as per the tags present in the input string.

Kaashan
  • 352
  • 3
  • 12