I'm trying to accomplish something specific in Angular2 - emitting a custom event globally and having multiple components listen to it, not just following the parent-child pattern.
Within my event source component, I have:
export class EventSourceComponent{
@Output() testev = new EventEmitter();
onbtnclick(){
this.testev.emit("I have emitted an event")
}
}
Now, I want other components to receive this event:
export class CmpTwoComponent{
//Receive the emitted event with data here
}
How can I achieve the above?