title: Angular - How to fix 'property does not exist on type' error?
body: <p>I am following <a href="https://www.youtube.com/watch?v=4lSvgj8ohAI&amp;list=PL6n9fhu94yhXwcl3a6rIfAI7QmGYIkfK5&amp;index=30" rel="noreferrer">this video tutorial</a> (<a href="https://csharp-video-tutorials.blogspot.in/2018/03/angular-5-services-tutorial.html" rel="noreferrer">text version of the same</a>). I have followed exactly the same code and I am receiving this error:</p>
  
  <blockquote>
    <p>error TS2339: Property 'getEmployees' does not exist on type
    'EmployeeService'</p>
  </blockquote>
  
  <p>I looked on the Internet and visited many questions on Stack Overflow like <a href="https://stackoverflow.com/questions/42764043/angular2-property-does-not-exist-on-type">this</a>, <a href="https://stackoverflow.com/questions/40097820/property-does-not-exist-on-type-object-observable-subscribe">this</a>, <a href="https://stackoverflow.com/questions/47356913/angular-2-property-does-not-exist-on-type">this</a> and <a href="https://stackoverflow.com/questions/38324949/error-ts2339-property-x-does-not-exist-on-type-y">this</a>, and so many others issues opened related to this error on GitHub.</p>
  
  <p><strong>Service:</strong></p>
  
  <pre><code>//import statements go here ...
  
  @Injectable()
  export class EmployeeService {
  private listEmployees: Employee[] = [
      {
        //just to avoid longer code, deleted dummy data.
      },
    ];
  
    getEmployees(): Employee[] {
        return this.listEmployees; //ERROR in src/app/employees/list-employees.component.ts(14,44)
    }
  }
  </code></pre>
  
  <p><strong>Component class:</strong></p>
  
  <pre><code>//import statements
  @Component({
      selector: 'app-list-employees',
      templateUrl: './list-employees.component.html',
      styleUrls: ['./list-employees.component.css']
  })
  export class ListEmployeesComponent implements OnInit {
      employees: Employee[];
      constructor(private _EmployeeService: EmployeeService) { }
  
      ngOnInit() {
          this.employees = this._EmployeeService.getEmployees();
      }
  
  }
  </code></pre>
  
  <p>I have imported service in <code>app.module.ts</code> and added it in providers array of <code>ngModule</code>.</p>
  
  <p>I am not able to solve the error neither to understand what is causing this error.</p>