ssougnez
ssougnez

Reputation: 5876

Compile html with angular2

I'm having a component that makes an http request in its ngOnInit function. This call retrieves the content of the page that can contains angular directives such as routerLink or even angular2 custom component.

I found the way to inject this content in a div (using the innerHTML property), however, the inserted content does not get compiled by "angular2" resulting in routerLink being just an attribute without effect. And of course, the components don't appear.

Is there a simple way to ask angular2 to compile the inserted HTML?

Upvotes: 0

Views: 242

Answers (1)

Brivvirs
Brivvirs

Reputation: 2493

As far as i understand angular takes template html and generate js factory code from it. When component is loaded, there is no way to change specified template

Upvotes: 1

Related Questions