-1
import {Http, HTTP_PROVIDERS} from '@angular/http';

When I use http I get a error that "No provider for Http",

then I import HTTP_PROVIDERS but HTTP_PROVIDERS has no exported member

toney
  • 35
  • 5

2 Answers2

0

I have created plunker on inserting http. Read more about http module

import {HttpClientModule} from '@angular/common/http';

@NgModule({
 imports: [ BrowserModule, HttpClientModule ],
 declarations: [ App ],
 bootstrap: [ App ]
})
export class AppModule {}
alexKhymenko
  • 5,450
  • 23
  • 40
0

HTTP_PROVIDERS was deprecated in current version. But which verions of angular cli, angular compiler, and angular core do you use? in latest version, you have to use this:

/* in app.module.ts */
import { HttpModule } from '@angular/http';


@NgModule({
  imports: [BrowserModule, HttpModule],
  ....
}
nickj
  • 330
  • 1
  • 7
  • 15
  • @angular/cli: 1.3.2 node: 6.11.0 os: win32 x64 @angular/animations: 4.3.6 @angular/common: 4.3.6 @angular/compiler: 4.3.6 @angular/core: 4.3.6 @angular/forms: 4.3.6 @angular/http: 4.3.6 @angular/platform-browser: 4.3.6 @angular/platform-browser-dynamic: 4.3.6 @angular/router: 4.3.6 @angular/cli: 1.3.2 Here is my angular version just only import HttpModule It is not work – toney Sep 14 '17 at 02:02
  • Hi toney, as I commented, you have to use HttpModule, and then import that to @NgModule. – nickj Sep 14 '17 at 02:04