linkXHRBackend
npm Package | @angular/http |
---|---|
Module | import { XHRBackend } from '@angular/http'; |
Source | http/src/backends/xhr_backend.ts |
linkDeprecation Notes
use @angular/common/http instead
linkOverview
class XHRBackend implements ConnectionBackend {
constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy)
createConnection(request: Request): XHRConnection
}
linkDescription
Creates XHRConnection
instances.
This class would typically not be used by end users, but could be overridden if a different backend implementation should be used, such as in a node backend.
linkExample
import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '@angular/http';
@Component({
viewProviders: [
HTTP_PROVIDERS,
{provide: Http, useFactory: (backend, options) => {
return new Http(backend, options);
}, deps: [MyNodeBackend, BaseRequestOptions]}]
})
class MyComponent {
constructor(http:Http) {
http.request('people.json').subscribe(res => this.people = res.json());
}
}
linkConstructor
constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy)
linkMembers
createConnection(request: Request): XHRConnection
linkAnnotations
@Injectable()