title: Can't get property from service Angular 5
body: <p>I've been learning Angular during a week by doing a simple web store. I'm still on the basis and I'm trying to load a menu with data from a REST service. For that I'm using the following configuration:</p>
  
  <p><strong>categories.services.ts</strong></p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Http }  from '@angular/http';
  
  
  @Injectable()
  export class CategoriesService {
  
      private categories = [];
  
      constructor(private http: Http){
          this.setCategories();
      };
  
      setCategories(){
          if (this.categories != []){
              this.http.get('http://someurl:1234/someapi/somevalue')
              .toPromise()
              .then((data) =&gt; {
                  console.log('inside');
                  console.log(data.json().response);
                  this.categories = data.json().response;
              })
              .catch((err) =&gt; {
                  console.log(err);
              })
          }
      }
  
      function getCategories(){
          return this.categories; 
      }
  
  }
  </code></pre>
  
  <p><strong>main.component.ts</strong></p>
  
  <pre><code>import { Component, OnInit, Inject } from '@angular/core';
  import { CategoriesService } from '../categories/categories.service';
  
  @Component({
      selector: 'app-main',
      templateUrl: './main.component.html',
      styleUrls: ['./main.component.css']
  })
  
  export class MainComponent{
  
      categories = [];
  
      constructor(private cat:CategoriesService){
          this.categories = cat.getCategories;
          console.log(this.categories);
      }
  
      notify(private new_categories){
          this.categories = new_categories;
      }
  
  }
  </code></pre>
  
  <p>The problem here is that <strong>in the web console I can see the response of the REST service as expected, but the log inside the component prints an empty array</strong>. Thank you and sorry my English</p>