title: Detect Data Chages When Another Component Make a POST or a PUT Request
body: <p>Mainly, I'm using angular2 and I have two components, the first one is responsible for displaying the data coming from the server on my page, the second one <strong>which is an ngmodal</strong> that pops up, is responsible for doing POST and PUT request to save the data.</p>
  
  <p><strong>the problem</strong> here is that when I change or add data, it doesn't get displayed automatically in my view.</p>
  
  <p>Does any one know how to make that happens (make component A aware of the changes made by component B) ? thanks.</p>
  
  <p>How I'm fetching data (component A) :</p>
  
  <pre><code>this.service.getData(this.url)
    .subscribe(data =&gt; {
      this.data = data;
      console.log(this.data);
    },
    err =&gt; { console.log('__error__') },
    () =&gt; { console.log('Success') }
    );
  </code></pre>
  
  <p>How I'm posting data (component B):</p>
  
  <pre><code>add(content: string): void {
  if (!content) { return; }
  this.service.create(content, this.url)}
  </code></pre>
  
  <p>My service.get Data:</p>
  
  <pre><code>getData(url:string): Observable&lt;Object[]&gt; {
  return this.http.get(url)
    .map(res =&gt; res.json())
    .catch(this.handleError);}
  </code></pre>
  
  <p>My service.create (post example): </p>
  
  <pre><code>create(content: string, url:string): Observable&lt;Object&gt; {
      return this.http
          .post(url, JSON.stringify({ content: content }), { headers: this.headers})
          .map(res =&gt; res.json())
          .catch(this.handleError);}
  </code></pre>