title: Angular 7 TypeError: service.x is not a function
body: <p>I made a routing service and want to inject it into my nav component. But when i call a method on it it throws <code>TypeError: routingService.getRequestedPage is not a function</code>. Yesterday I had a very similar problem with another service, unfortunately I forgot how I solved this. I generated the service it with the terminal. </p>
  
  <p><code>src/app/nav/nav.component.ts</code> constructor:</p>
  
  <pre class="lang-js prettyprint-override"><code>constructor(private templateService: TemplateService, private routingService: RoutingService) {
      this.getTemplates();
      if (this.routingService.getRequestedPage() === 'home') {
        this.showHome();
      }
    }
  </code></pre>
  
  <p><code>src/app/nav/nav.component.ts</code> import:</p>
  
  <pre class="lang-js prettyprint-override"><code>import {RoutingService} from '../shared/routing.service';
  </code></pre>
  
  <p><code>src/app/shared/routing.service.ts</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
  
  @Injectable({
    providedIn: 'root'
  })
  export class RoutingService {
  
    private requestedPage: string;
  
    constructor() {
      this.requestedPage = 'home';
    }
  
    requestPage(page: string) {
      this.requestedPage = page;
    }
  
    getRequestedPage() {
      return this.requestedPage;
    }
  }
  </code></pre>