Reputation: 589
How to render a html using a string variable (holding template) - Angular4.
sample.component.ts
let stringTemplate = "<div><p>I should be rendered as a HTML<br></p></div>";
sample.component.html should be rendered based on elements in variable stringTemplate
NOTE: stringTemplate is not static. Will be getting its data from server.
Upvotes: 4
Views: 3501
Reputation: 284
You can bind to the innerHtml property.
<div [innerHtml]="stringTemplate"></div>
Upvotes: 5