Greetings to all
I currently have 3 components that are communicating with each other. I know that with decorators @input
I can pass information from father to son. But I don't know how I can execute a child method from the parent.
How can I make it so that when the component method is executed, the component method is guardarSolicitud()
also Solicitud
executed .servicioAPIGuardar()
Codeudor
This is due to the fact that when saving the request, an id is obtained that is used to relate to deudores
the solicitud
in the DB.
For something like
guardarSolicitud() {
let solicitudData: any = {
...this.solicitudForm.value,
};
this.solicitudesService.createSolicitud(solicitudData)
.pipe(finalize(() => {
this.wizard.next();
window.scroll(0, 0);
}))
.subscribe(data => {
this.solicitudArrendamiento = data;
this.idSolicitud = data['id']; // El idSolicitud se está enviado por medio de un @input.
servicioAPIGuardar(); //Este método no esta aquí, pero es donde quiero que se ejecute.
}, error => {
log.debug(`Solicitud error: ${error.message}`);
}
);
}
You have several ways to solve this problem but I exemplify the two most common:
Service
parent component
child component
parent component