Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Angular2 - Unable to import http module

overexchange:

Answer did not help me Import Http Module without error.


Below code,


//app.module.ts
import {HttpClientModule} from '@angular/common/http';

@NgModule({
declarations: [
AppComponent,
HomeComponent,
DirectoryComponent,
FilterPipe,
LoggingService
],
imports: [
FormsModule,
BrowserModule,
HttpClientModule,
routing
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }


and service code,


import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';

@Injectable()
export class DataService {

constructor(private http: HttpClient) { }

}


gives error:


ERROR in src/app/data.service.ts(2,9): error TS2305: Module '"/home/mohet01/My_Websites/Youtube_sites/angular_2_playlist/ninja-directory/node_modules/@angular/http/http"' has no exported member 'HttpClient'.


Why HttpClient service cannot be injected in the constructor of service code?



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Angular2 - Unable to import http module

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×