Angular 8: await till son component is created

43 Views Asked by At

I have a 'father' component which has few 'son-s' components. The 'father' creates 'sons' by the following code:

export class FatherComponent implements OnInit, AfterViewInit {
    @ViewChildren(SonComponent, { read: ViewContainerRef }) sonComponent: QueryList<ViewContainerRef>
    sonTitle: string;
    items: number[];

    public CreateChildren(val: any) {
        let NofChildren = val;
        this.items = new Array(NofChildren);

        //Wait till number of sons=2
    }
}
<div>
    <p-tabView [styleClass]="'main'">
        <p-tabPanel [header]='sonTitle+(i+1)' *ngFor="let item of items; let i = index" [selected]="i == 0">
            <app-page #sonComponent ></app-page>
        </p-tabPanel>
    </p-tabView>
</div>

Can you please explain: How should I "wait" till all 'sons' are created ?

Thank you in advance, Zvika

0

There are 0 best solutions below