FRANCISCO J. BLANCO
FRANCISCO J. BLANCO

Reputation: 208

Is there any way my child component does not initialize when I load the parent in Angular 8?

I'm having a problem when I enter the form that would be the parent component that automatically loads the methods that the child component has on the OnInit, this adds a bit more load to my parent component

Is there any way that my child component starts when I click a button or otherwise?

Inside my father's html I have the son in this way

<app-solicitud-servicios #solicitud1></app-solicitud-servicios>

Upvotes: 0

Views: 640

Answers (1)

Josh Freed
Josh Freed

Reputation: 61

You can use *ngIf to only show it when some criteria is met. That could be after clicking a button, or whatever you want.

<app-solicitud-servicios *ngIf="buttonWasClicked" #solicitud1></app-solicitud-servicios>

It won't call OnInit in the child until the *ngIf condition is true.

Upvotes: 1

Related Questions