title: Angular 5 refresh component from service
body: <p>I am somehow struggling to get a grasp of the architecture.</p>
  
  <p>I have a search component, a table component, a table service.</p>
  
  <ol>
  <li><p>When I do a search I call a rest webservice and getback a JSON. I store this json using a tableservice.setData();</p></li>
  <li><p>I go to the table component page it is working and my data is in the table</p></li>
  <li><p>I search again but this time on the table component page (after it has been initialized) and it is not getting updated as it is already instanciated and it is not going through the component constructor again.</p></li>
  </ol>
  
  <p>What am I missing is a way to force a refresh of the table component within the table service when my data changes.</p>
  
  <p>Is there any way to achieve this?</p>
  
  <p><strong>tablecomponent.ts</strong></p>
  
  <pre><code>constructor(private service: SmartTableService) {
      console.log("entering constructorSTable")
      const data = this.service.getData();
      this.source.load(data);
  }
  </code></pre>
  
  <p><strong>searchcomponent.ts</strong></p>
  
  <pre><code>constructor(private searchService: NbSearchService,
              private http: HttpClient, 
              private myTableService : SmartTableService ) {}
  
  ngOnInit(): void {
      this.searchService.onSearchSubmit()
              .subscribe((data: { term: string, tag: string }) =&gt; {
                   var req = this.http.post('http://...', {
                   ...
      }).subscribe(
          res =&gt; {
            var ApiRet = res;
            this.myTableService.setData(ApiRet);
          },
          err =&gt; {
            console.log("Error occured");
          }
        );
    });
  </code></pre>
  
  <p>the tableservice just contains a setter and getter for the data.</p>