Angular2 Http v.s HTTP_PROVIDERS

Viewed 8167

I read an article for how to inject Http service into an Angular2 application.

https://angular.io/docs/ts/latest/api/http/HTTP_PROVIDERS-let.html

import {HTTP_PROVIDERS, Http} from 'angular2/http';

@Component({
  selector: 'app',
  providers: [HTTP_PROVIDERS],
....

I thought Http service already included in the HTTP_PROVIDERS. (as below, according to the document).

"The providers included in HTTP_PROVIDERS include:

Http
XHRBackend
BrowserXHR - Private factory to create XMLHttpRequest instances
RequestOptions - Bound to BaseRequestOptions class
ResponseOptions - Bound to BaseResponseOptions class"

If that's the case, how come we still need to import Http in? Can we only do

 import {HTTP_PROVIDERS} from 'angular2/http';

On the other hand, be more specifically, can we change the component providers to providers: [Http]? Or in the bootstrap, can we do bootstrap(app, [Http])?

2 Answers
Related