Angular 2 hierarchical providers in ES5

I am starting to use Angular 2 with ES5 and I hit a brick wall when setting up my providers. Essentially, I want the provider to depend on HTTP. Here's how I set it up:

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
    }]
});

I keep getting the following error: No provider for t! (e -> t)

I skipped the rest of the template code because it was here that I was stuck. Do I have a misunderstanding about how I add my dependencies? How to set up hierarchical dependencies in Angular 2 in ES5?

+4
source share
1 answer

I get it. In the actual code that I used, I got something like this: providers: [[Provider, ng.http,HttpProviders]]which should not have been a nested array

+1

All Articles