angular-docs-cn/public/docs/js/latest/api/http/XHRBackend-class.jade

70 lines
1.5 KiB
Plaintext

p.location-badge.
exported from <a href='../http'>angular2/http</a>
defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.37/modules/angular2/src/http/backends/xhr_backend.ts#L80-L114">angular2/src/http/backends/xhr_backend.ts (line 80)</a>
:markdown
Creates <a href='XHRConnection-class.html'><code>XHRConnection</code></a> 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.
#Example
```
import {Http, MyNodeBackend, HTTP_BINDINGS, BaseRequestOptions} from 'angular2/http';
@Component({
viewBindings: [
HTTP_BINDINGS,
bind(Http).toFactory((backend, options) => {
return new Http(backend, options);
}, [MyNodeBackend, BaseRequestOptions])]
})
class MyComponent {
constructor(http:Http) {
http('people.json').toRx().subscribe(res => this.people = res.json());
}
}
```
.l-main-section
h2 Annotations
.l-sub-section
h3.annotation Injectable
pre.prettyprint
code.
@Injectable()
.l-main-section
h2 Members
.l-sub-section
h3#constructor constructor
pre.prettyprint
code.
constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions)
:markdown
.l-sub-section
h3#createConnection createConnection
pre.prettyprint
code.
createConnection(request: Request)
:markdown