title: How can i capture an event in a component which is emitted from another component?
body: <p>I want to capture the event in a component which is emitted event from another component.</p>
  
  <p>I did the following code</p>
  
  <p><strong>myservice.ts</strong></p>
  
  <pre><code>private _event = new EventEmitter&lt;any&gt;();
  
  get event(): EventEmitter&lt;any&gt; {
    return this._event;
  }
  </code></pre>
  
  <p><strong>mycomponent_2.ts</strong></p>
  
  <pre><code>this.myservice.event.emit(true);
  </code></pre>
  
  <p><strong>mycomponent_1.ts</strong> - Added the below code in ngOnInit()</p>
  
  <pre><code>this.myservice.event.subscribe((value) =&gt;  {
    console.log(value);
  });
  </code></pre>
  
  <p>The expected console log not printed. Looks the event is not captured in the component_2</p>
  
  <p>How can I solve this? Do I need to move the code to some other life cycle hook?</p>