0

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?

ssougnez
  • 5,315
  • 11
  • 46
  • 79
  • To create dynamic components, see these answers the solution is there https://stackoverflow.com/questions/38888008/how-can-i-use-create-dynamic-template-to-compile-dynamic-component-with-angular/39773331#39773331 – titusfx Jul 26 '17 at 08:43

1 Answers1

1

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

Brivvirs
  • 2,461
  • 3
  • 18
  • 31