One can use Output() decorator to emit the event from the child component so that the parent component can catch it. What I need is to catch an event emitted by
the thierry answer is the correct aproach, but if you want to avoid use shared service, you can do somthing like this
view.html
view.ts
actionHandler(event){
//doSomething
}
componentA.html
componentA.ts
@Output() actionA: EventEmitter<{}> = new EventEmitter();
constructor() {
}
actionHandlerA(event){
this.actionA.emit(event);
}
componentB.html
click me
componentB.ts
@Output() actionB: EventEmitter<{}> = new EventEmitter();
constructor() {
}
actionHandlerB(o: objectModel){
this.actionB.emit(new objectModel(o));
}