This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

XHRBackend

Creates XHRConnection instances.

See more...

Deprecated: see https://angular.io/guide/http

      
      class XHRBackend implements ConnectionBackend {
  createConnection(request: Request): XHRConnection
}
    

Description

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.

Methods

createConnection(request: Request): XHRConnection
      
      createConnection(request: Request): XHRConnection
    

Parameters

request

Type: Request.

Returns

XHRConnection

Usage notes

Example

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()); } }
      
      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());
  }
}