I am trying to render dynamic HTML into an angular component. The problem is the dynamic HTML Content may have angular expressions in it and I want it to be rendered also. I have tried DomSanitizer and Component Factory Methods (links below), but I couldn't get the job done. Basically I want angular to compile template code on the go.
@component ({
template : `{{ htmlCodeWithAngularExperssion }}`
)}
export class SomeComponent {
this.htmlCodeWithAngularExperssion = `Hello, I am {{ name }} !
and My Hobbies are :
<span *ngFor="let hob of hobbies" >{{ hob }}</span>`;
this.name = 'Sreenivas';
this.hobbies = ['Video Games', 'Treckking'];
}
}
DomSanitizer Method : Angular 2: sanitizing HTML stripped some content with div id - this is bug or feature?
Component Factory : Equivalent of $compile in Angular 2