Lets say I have the below HTML Template whats the best way to assign it to a variable in Angular Project
public template = '<html><body> <p>This is a p tag</p>
</body></html>'
How do I make such kind of assignment in typescript?
Lets say I have the below HTML Template whats the best way to assign it to a variable in Angular Project
public template = '<html><body> <p>This is a p tag</p>
</body></html>'
How do I make such kind of assignment in typescript?
public template = '<p>This is a p tag</p>'
In the Html
<div [innerHtml]="template"></div>
If you have a project that work with Angular 7.^, you can use a binding with
<div [innerHtml]='template"></div>
Where template
is declared in component like
template = '</p>This is a p ta</p>'
If your version is older then 7 you must sanitize your bindig with
<div [innerHTML]="template | safeHtml"></div>
Anyway, why declare a variables public if is the default value?