4

I have product data from database contains title, description... The description is in html format string, like this:

<b>Name:</b> iPhone 5;<br>
<b>Membery:</b> 8GB;<br>
<b>Condition:</b> Brand new;<br />

if supposed to be displayed like this:

Name: iPhone 5;

Memory: 8GB;

Condition: Brand new

But when I use data-binding in Angular2: {{product.description}}, it displays like pure text:

<b>Name:</b> iPhone 5; <br /><b>Memory:</b> 8GB;<br /><b>Condition:</b> Brand new;<br />

How should I display it correctly as html ? there is no html filter for the binding.

Blockchain Nerd
  • 427
  • 5
  • 11

1 Answers1

14

You can bind to innerHTML:

<div [innerHTML]="product.description"></div>
Günter Zöchbauer
  • 558,509
  • 191
  • 1,911
  • 1,506