Why is my EventEmitter
not working?
Calling the function sendInstruction()
the EventEmitter
doesn't work, but testing in ngOnInit
the event reaches on parent component, what is happening?
child component.ts
@Output() updateInstruction = new EventEmitter<boolean>();
sendInstruction() {
this.objDetails = this.titleDetails.DetalhesTitulo
const send: SendInstruction = {
...
}
this.service.sendInstruction(send, this.objDetails.NN_ABC).subscribe({
next: () => {
this.emitInstruction(true)
},
error: () =>
...,
});
}
emitInstruction(emit){
this.updateInstruction.emit(emit)
}
child component.html
<button class="abc-button select medium col-top" mat-raised-button color="primary" [disabled]="!hasInstruction || formInstructions.invalid"
(click)="sendInstruction()">
Send Instruction
</button>
parent component.ts
getDetailsUpdate(update) {
console.log(update);
}
parent component.html
<abc-instruction-billet (updateInstruction)="getDetailsUpdate($event)"></abc-instruction-billet>
this.service.sendInstruction
is your observable emitting any value? What does it return? – Tombery