title: get the data from one component to other in angular 7
body: <p>I have 2 components namely A and B. The component A catches a event when some some event is fired. I mean to say it shows some message as "Job 1 is Running". So here whatever the message the comonent A is showing the same message i have to show it on the component B. For that i have written the code something like this: Here in when i click the event run button it will check the entry.status == 'In_progress', if this condition matches then in the component A i will get the message as "Job 1 is running" something like. I want to catch the same message in component B also. For that i have added some code see below:</p>
  
  <p><strong>componentA.component.ts</strong></p>
  
  <pre><code>tasks(){
  this.tasksRes = results['data'];
  this.count = 0;
        for (let entry of this.tasksRes) {
          if (entry.status == 'In_progress') {
            this.count = this.count + 1;
          }
        }
  }
  
  connect(){
        let source = new EventSource('/api/v1/events/register');
        source.addEventListener('message', message =&gt; {
            this.tasks();
        });
    }
  </code></pre>
  
  <p><strong>componentA.component.html</strong></p>
  
  <pre><code>&lt;ul class="p-0" *ngFor="let task of tasksRes"&gt;
  &lt;li&gt;
  &lt;span class="text-muted"&gt;{{task.eventType}}&lt;/span&gt;
  &lt;/li&gt;
  &lt;ul&gt;
  </code></pre>
  
  <p>The above code shows the message as "Job 1 running".</p>
  
  <p>I am trying to get the "task.eventType" in component B also. so how can we achieve it. How can i get the same status here in component B also. Help is highly appreciated.</p>
  
  <p>Thanks</p>