1 import http and Inject
1
|
import
{httpInjectables, Http} from
'angular2/http'
;
|
1
|
import
{Inject} from
'angular2/di'
;
|
2 init your Http and use it
1
2
3
4
5
6
7
8
9
10
11
12
|
class
App {
http:Http;
status:int;
constructor(@Inject(Http) http) {
this
.http = http;
this
.http.get(
'test.json'
).toRx().subscribe((res:Response) => {
this
.status = res.status;
});
}
}
|
3 show the result in the UI
1
|
{{status}}
|