title: how to return object from service to component in angular 2?
body: <p>I would like to get results array from atom.service into atom.component. I thought I could bring in results array into atom.component with source codes below (not presented whole codes). But I found I could not access this.atoms in atom.component from source codes below. The results array in atom.service.ts was created successfully. If anyone knows about how to get access to results array in the atom.component, could you give some guide about it?</p>
  
  <p>atom.service.ts</p>
  
  <pre><code>getAtoms(private newConcept: string) {
      this.http.get('api/atoms.json')
      .map( (responseData) =&gt; {return responseData.json()})
      .subscribe( data =&gt; {   
          let results:Array&lt;RAtom&gt; = [];
          for (i = 0; i &lt; data.result.length; i++) { 
              results.push(new RAtom(data.result[i].classType, data.result[i].ui));
          }
          return results;
      });
  }
  </code></pre>
  
  <p>atom.component.ts</p>
  
  <pre><code>atoms: Array&lt;RAtom&gt;;
  
  searchAtoms(newConcept: string) {
      if (newConcept) {
      this.atoms = this.service.getAtoms(newConcept);
      }
  }
  </code></pre>
  
  <p>RAtom.ts</p>
  
  <pre><code>export class RAtom {
      classType: string;
      ui: string;
  
      constructor(classType: string, ui:string) {
        this.classType = classType;
        this.ui = ui;
      }
  }
  </code></pre>