達成しようとしています私は、グローバルangular2でカスタムイベントを放出し、複数のコンポーネントが私のイベント・ソース・コンポーネントではそうではないだけで親子パターン発光イベントグローバル
それに耳を傾けるがしたいですが、私は持っています
export class EventSourceComponent{
@Output() testev = new EventEmitter();
onbtnclick(){
this.testev.emit("i have emitted an event")
}
}
今私はどのように私は上記目的を達成ん
export class CmpTwoComponent{
//here get the emitted event with data
}
このイベントを取得するために他のコンポーネントをご希望ですか?
サービス内では 'EventEmitter'を使用しないでください。 https://stackoverflow.com/questions/36076700/what-is-the-proper-use-of-an-eventemitter代わりに 'Observable' /' Subject'を使用してください。 – echonax
素晴らしいmiladありがとう –