6

I am inserting dynamic page content like this in angular 4:

<app-component>
    <main [innerHTML]="dynamicHTML"></main>
</app-component>

Which will render to:

<app-component>
    <main>
        <div>
            <div id="insertionPoint">
            </div>
        </div>
    </main>
</app-component>

Is it possible to get a ViewContainerRef of the div#insertionPoint that has been dynamically added. The div#insertionPoint could be anywhere in a large HTML document that is loaded into <main>.

I would like to use the ViewContainerRef.createComponent() along with the ComponentFactoryResolver to insert an Angular Component inside the dynamic HTML.

arniebradfo
  • 1,141
  • 11
  • 18
  • 2
    No you can't. There is alternative option `factory.create(injector, [], element)` where `element` is specific dom element – yurzui Jun 03 '17 at 16:20

0 Answers0