2016-02-28 67 views

回答

3

假設你在阿爾法49或更高版本(你應該至少在公測.0)並且您使用的是UMD套件,正確的答案是使用ng.http.Httpng.http.HTTP_PROVIDERS

var App = ng.core. 
      Class({ 
      constructor: [ng.http.Http, function(http) { 
       /* Do something with http */ 
      }] 
      }); 

document.addEventListener('DOMContentLoaded', function() { 
    ng.platform.browser.bootstrap(App, [ng.http.HTTP_PROVIDERS]); 
}); 

這裏有一個動作示例的plnkr

0

如果使用ES6(但不是打字稿),你需要創建一個getter方法的參數場:

export class SomeClass { 
    constructor(http) {} 

    static get parameters() { 
    return [[Http]]; 
    } 
}