39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
|
|
.l-main-section
|
|
h2(class="function export") HttpFactory
|
|
|
|
|
|
pre.prettyprint
|
|
code.
|
|
HttpFactory(backend: XHRBackend, defaultOptions: BaseRequestOptions)
|
|
|
|
|
|
p.location-badge.
|
|
exported from <a href='../http'>angular2/http</a>
|
|
defined in <a href="https://github.com/angular/angular/tree/3a0410a/modules/angular2/src/http/http.ts#L149-L182">angular2/src/http/http.ts (line 149)</a>
|
|
|
|
:markdown
|
|
Alias to the `request` method of <a href='Http-class.html'><code>Http</code></a>, for those who'd prefer a simple function instead
|
|
of an object. In order to get TypeScript type information about the `HttpFactory`, the <a href='IHttp-interface.html'><code>IHttp</code></a> interface can be used as shown in the following example.
|
|
|
|
#Example
|
|
|
|
```
|
|
import {httpInjectables, HttpFactory, IHttp} from 'angular2/http';
|
|
@Component({
|
|
appInjector: [httpInjectables]
|
|
})
|
|
@View({
|
|
templateUrl: 'people.html'
|
|
})
|
|
class MyComponent {
|
|
constructor(@Inject(HttpFactory) http:IHttp) {
|
|
http('people.json').subscribe(res => this.people = res.json());
|
|
}
|
|
}
|
|
```
|
|
|
|
|
|
|
|
|