Why is ViewChildren not working with dynamic component?

I'm looking for ways to inject values ​​into a dynamic component using ngComponentOutlet. My last attempt, before asking, was:

in parentComponent.html:

<ng-container *ngComponentOutlet="getButtonComponent()"></ng-container>

      

and in parentComponent.ts

@ViewChildren(ButtonComponent, { read: ViewContainerRef}) list: QueryList<ButtonComponent>;

      

and the list is empty, shouldn't that be correct? This should be a workaround to get and set a dynamic component created dynamically

+3


source to share





All Articles