标签:
1 import http and Inject
import {httpInjectables, Http} from ‘angular2/http‘;
import {Inject} from ‘angular2/di‘;
2 init your Http and use it
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
{{status}}
标签:
原文地址:http://www.cnblogs.com/lihaozhou/p/4671910.html