1

Good morning all as indicated in the title

I want to declare a link as string then use it in the template and here is my code

.ts

  array=["<a href=\"https://example1.com\">Website1</a>","<a href=\"https://example2.com\">Website2</a>"]

.html

<table>
  <tbody>
  <tr>
    <td *ngFor="let item of array" >{{item}}</td>

  </tr>
  </tbody>
</table>

it displays this
enter image description here

instead of this
enter image description here

jakehard
  • 67
  • 7

1 Answers1

3

Angular escapes out all strings you bind by default, so you need to tell angular to not escape the string and let it be actual HTML.

You need to bind to innerHTML as shown here: Angular HTML binding

Zachary Haber
  • 10,376
  • 1
  • 17
  • 31