title: ERROR in src/app/app.component.ts(19,25): error TS2339: Property 'getUsers' does not exist on type 'Dataservice'
body: <p>I am new to Angular,</p>
  
  <p>Trying to create function that will fetch record from MongoDB database, however getting an issue. API URL is working fine.</p>
  
  <p><strong>File: data.services.spec.ts</strong></p>
  
  <pre><code>import { Injectable } from '@angular/core';
  
  
  import { Http, Headers, RequestOptions } from '@angular/http';
  import 'rxjs/add/operator/map';
  import 'rxjs/Rx';
  
  @Injectable()
  
  export class DataService {
  
    result:any;
  
    constructor(private _http: Http) { }
  
    getUsers() {
      return this._http.get("/api/users")
            .map(result =&gt; this.result = result.json().data);
    }
  
  }
  </code></pre>
  
  <p><strong>File: app.module.ts</strong></p>
  
  <pre><code>import { BrowserModule } from '@angular/platform-browser';
  import { NgModule } from '@angular/core';
  
  import { AppComponent } from './app.component';
  
  // Import the Http Module and our Data Service
  import { HttpModule } from '@angular/http';
  import { DataService } from './data.service';
  
  @NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
      BrowserModule,
      HttpModule
    ],
    providers: [ DataService ],
    bootstrap: [AppComponent]
  })
  export class AppModule { }
  </code></pre>
  
  <p><strong>File: app.component.ts</strong></p>
  
  <pre><code>import { Component } from '@angular/core';
  
  // Import the DataService
  import { DataService } from './data.service';
  
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent {
    title = 'mean';
  
      // Define a users property to hold our user data
      users: Array&lt;any&gt;;
      // Create an instance of the DataService through dependency injection
      constructor(private _dataService: DataService) { 
        // Access the Data Service's getUsers() method we defined
        this._dataService.getUsers()
            .subscribe(res =&gt; this.users = res);
      }
  }
  </code></pre>
  
  <p>Error is here <code>this._dataService.getUsers()</code>.
  Any suggestion would be appreciated.</p>