How can I add a html element dynamically using string interpolation without add any html tag? Exp:
This is my obj in my component
myObj = {
title: 'Header Title',
icon: '<i class="fa fa-user">'
}
I want to add this like;
<header>
{{myObj.title}} - {{myObj.icon}}
</header>
{{myObj.icon}} rendered as text, but I want render as html. How can?
I want the result to be as follows
<header>
Header Title <i class ="fa fa-user"></i>
</header>
and if I change my obj like this;
myObj = {
title: 'Header Title',
icon: '<mat-icon>search</mat-icon>'
}
render as
<header>
Header Title <mat-icon>search</mat-icon>
</header>
<header>
<span>{{myObj.title}}</span> - <span [innerHTML]="myObj.icon"></span>
</header>
Note : I have used to segregated the elements however you can pick any element as per your design.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With