2015-05-18 49 views

回答

5

我認爲已經添加了基本支持。在此基礎上example:從 'angular2/HTTP' //index.ts

    1. 引導與httpInjectables您的應用程序只需要使用HTTP它在構造函數的構造函數注入(HTTP:HTTP)// http_comp。 TS

    2. http.get('./people.json').map(res => res.json()).subscribe(people => this.people = people);

  • 0

    下面是摘錄:

    import {Component, View} from 'angular2/core'; 
    import {Http, HTTP_BINDINGS} from 'angular2/http'; 
    import {bootstrap} 'angular2/platform/browser'; 
    import {CORE_DIRECTIVES,NgFor} from 'angular/common'; 
    
        @Component({ 
         selector: 'app' 
        }) 
    
        @View({ 
         templateUrl: 'devices.html', 
         directives: [CORE_DIRECTIVES,NgFor] 
        }) 
    
        export class App { 
         devices: any; 
         constructor(http: Http) { 
          this.devices = []; 
          http.get('./devices.json').toRx().subscribe(res => this.devices = res.json()); 
         } 
        } 
    
        bootstrap(App,[HTTP_BINDINGS]); 
    

    下面是一個說明可能出現得心應手angular2 HTTP功能回購:

    https://github.com/kaalpurush/ng2-http