title: Angular 6: Service is undefined
body: <p>I'm using Angular for the first time and I'm trying to get a service running so I can get the contents of the file. I followed to heroes tutorial exactly where they explain how to do it and I did in the exact same way, but for some reason it doesn't work.</p>
  
  <p>I get an error saying <code>ERROR TypeError: "this.fileService is undefined"</code>, and I'm not sure what the issue is. </p>
  
  <p><code>about.component.ts</code></p>
  
  <pre><code>import { Component, OnInit } from '@angular/core'
  import { FileService } from './../file.service'
  
  declare var require:any;
  const markdown = require('markdown').markdown;
  
  @Component({
    selector: 'app-about',
    templateUrl: './about.component.html',
    styleUrls: ['./about.component.scss']
  })
  export class AboutComponent implements OnInit {
  
    constructor(private fileService:FileService) { }
  
    ngOnInit() {
      const aboutmeraw = this.fileService.readFile("./../assets/md/aboutme.md");
      this.aboutme = markdown.toHTML(aboutmeraw);
    }
  
    aboutme:string;
  
  }
  </code></pre>
  
  <p><code>file.service.ts</code></p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  import { Observable } from 'rxjs';
  
  @Injectable({
    providedIn: 'root'
  })
  export class FileService {
  
    constructor(private http:HttpClient) { }
  
    public readFile(file:string):Observable&lt;any&gt; {
      return this.http.get(file);
    }
  }
  </code></pre>
  
  <p>I know the method I return the HTTP file is wrong, but that's not the error I'm getting.</p>
  
  <p>What's going on and how can I fix it?</p>