码迷,mamicode.com
首页 > Web开发 > 详细

Angular2 Http

时间:2015-07-23 23:28:19      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:

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}}

  

Angular2 Http

标签:

原文地址:http://www.cnblogs.com/lihaozhou/p/4671910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!