I need to achieve dynamic variable compilation inside HTML Template using Angular 7.
Here is my sample code:
app.component.ts:
username = 'User Name';
sampleData = "This is my <strong>{{username}}</strong>";
app.component.html:
<div [innerHtml]="sampleData"></div>
But, still the output is
This is my {{username}}.
My Expected output is,
This is my UserName
The same feature can be achieved in Angular 1 using $compile
. Please let me know how to achieve this in Angular 7