I have 2 components b,c on the same level contained in a
a
b
c
c has raises events using EventEmitter eC in Output() that I want to consume in b. As I cannot "directly" feed that to b, I "redirected" those events by creating another EventEmitter eA that lives in a, that just replays incoming events eC. Then I pass this EventEmitter as an Input() to b:
//b
@Input() public reloadRequested: EventEmitter<void>;
ngOnInit() {
this.reloadRequested.subscribe(() => {
...
});
}
Is there anything wrong this approach? I was wondering because I basically did not find anything during my online researches. How would you do this otherwise?
UPDATE: I don't want to pass data to a component but an event. Using the Input() Decorator, referencing an EventEmitter of the parent component, seems to be the obvious way for me.