XHRBackend

Creates XHRConnectioninstances.

查看"说明"...

已弃用: see https://angular.io/guide/http

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

说明

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.

方法

createConnection(request: Request): XHRConnection
      
      createConnection(request: Request): XHRConnection
    
参数
request Request
返回值

XHRConnection

使用说明

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()); } }
      
      
  1. import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '@angular/http';
  2. @Component({
  3. viewProviders: [
  4. HTTP_PROVIDERS,
  5. {provide: Http, useFactory: (backend, options) => {
  6. return new Http(backend, options);
  7. }, deps: [MyNodeBackend, BaseRequestOptions]}]
  8. })
  9. class MyComponent {
  10. constructor(http:Http) {
  11. http.request('people.json').subscribe(res => this.people = res.json());
  12. }
  13. }