.l-main-section
h2(class="function export") HttpFactory
pre.prettyprint
code.
HttpFactory(backend: XHRBackend, defaultOptions: BaseRequestOptions)
p.location-badge.
exported from angular2/http
defined in angular2/src/http/http.ts (line 149)
:markdown
Alias to the `request` method of Http
, for those who'd prefer a simple function instead
of an object. In order to get TypeScript type information about the `HttpFactory`, the IHttp
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());
}
}
```