0
I have this post code:
postId(isSuccess:boolean = false){
let obj: any = {};
obj.card_reward = this.idCard;
return this.http.post(`${this.PATH_REWARD}`, obj).subscribe(
success => {if(success){
this.postSuccess.emit(true)
}},
error=> console.log("deu erro"),
()=> ("funcionou")
)
}
I defined Event that way : postSuccess = new EventEmitter <boolean>();
I wanted to know how I could manipulate this event in my other components, in case, after this value of "This.postSuccess" was true I could do something, I couldn’t find a simple way to understand
If you have a
EventEmitter
with their respective@Output
you need to subscribe to this in the parent component directly in the template. If it is not the parent element then it needs to have some observable in a service that any component can register, and generates the event in that observable– Isac