I have a table in a parent component that when clicking on a row, I painted a child component that was with ngIf to false until that moment.
At the moment that I want to paint the child component, call a function of the child and pass the row to it, and I do not just have to pass the data, I have to process it in the child, that's why I need to call a function
// view father
<jhi-gestion-imputacion-detalle
(volverEvent)="volverDetalle($event)"
[childReportesParte]="parentReportesParte"
[parentVerTabla]="childVerTabla"
*ngIf="!parentVerTabla"
>
</jhi-gestion-imputacion-detalle>
....
<tr (click)="detalle(parte)">
// controller father
ViewChild(GestionImputacionDetalleComponent) child: GestionImputacionDetalleComponent;
detalle(parte: GestionImputacionData) {
this.parentVerTabla = false;
this.parte = parte;
this.child.cargar(this.parte); <-- child is undefined
}
The problem is that "child" is undefined. What I see in the forums is "AfterViewInit", but that's when the controller starts, not like I need, that the child component is painted by clicking on a row of my parent component table.
How can I do so by clicking on the row of my table, I paint the child component and I can call a function of it, when it is created.