2016-02-28 52 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]]; 
    } 
}