Angular 4: Get ViewContainerRef of inserted dynamic HTML element

Viewed 1653

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.

0 Answers
Related