Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"@angular/http/index has no exported member of HTTP_PROVIDERS"

Dependencies

enter image description here

main.ts file

enter image description here

I want to import HTTP_PROVIDERS but is is giving me error that

"@angular/http/index has no exported member of HTTP_PROVIDERS"

I have attached images of package.json and main.ts file.

like image 488
Shehram Tahir Avatar asked Feb 16 '17 10:02

Shehram Tahir


1 Answers

HTTP-PROVIDERS is not used anymore. Import HttpModule to your ngModule instead and add it to your imports.

import { HttpModule } from '@angular/http';

@NgModule({
  imports: [
    ...
    HttpModule,
  ],
  declarations: [...],
  bootstrap: [ .. ],
  providers: [ ... ],
})

I suggest you always check angular.io page for current info. E.g, here usage of Http and everything that's needed is described :)

In the service you want to use http, you import Http and inject it in your constructor:

import { Http } from '@angular/http';

// ...

constructor(private http: Http) { }
like image 139
AT82 Avatar answered Oct 21 '22 20:10

AT82