[英]Angular 2 hierarchical Providers in ES5
我開始使用ES5開始使用Angular 2,並且在設置我的提供程序時遇到了困難。 本質上,我想讓提供者依賴於HTTP。 這是我如何設置它:
var Provider = ng.core.Class({
constructor: [ng.http.Http, function(http) {
// some code here that uses HTTP
}]
});
var Component = ng.core.Component({
providers: [Provider, ng.http.HTTP_PROVIDERS]
}).Class({
constructor: [Provider, function(provider) {
// some code here that uses my Provider
}]
});
我一直收到以下錯誤: No provider for t! (e -> t)
No provider for t! (e -> t)
我省略了其余的樣板代碼,因為這是我被困住的地方。 我是否對如何注入依賴關系有誤解? 如何在ES5中的Angular 2中設置層次依賴?
我想到了。 在我使用的實際代碼中,我最終得到了類似的東西: providers: [[Provider, ng.http,HttpProviders]]
這不應該是嵌套數組
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.