Utilizing a multi-provider is the next step I'm considering in order to export both dependencies of my dependency along with itself, allowing for them to be injected into a component simultaneously.
For example, when setting up a component:
import {Component} from 'angular2/core';
import { FOO_PROVIDERS } from './foo';
@Component({
selector: 'app',
providers: [FOO_PROVIDERS]
})
export class App {}
import {Inject, Injectable, provide} from 'angular2/core';
import {Http, HTTP_PROVIDERS} from 'angular2/http';
export class Foo {
constructor(@Inject(Http) http) {}
}
export const FOO_PROVIDERS = [
provide(Foo, { useClass: Foo, multi: true }),
provide(Foo, { useValue: HTTP_PROVIDERS, multi: true })
];
may lead to the error message:
No provider for Http! (App -> Foo -> Http)
However, if you consider this alternative approach
import {Inject, provide} from 'angular2/core';
import {Http, HTTP_PROVIDERS} from 'angular2/http';
class Foo {
constructor(@Inject(Http) http) {}
}
export const FOO_PROVIDERS = [Foo, HTTP_PROVIDERS];
you'll notice it functions correctly, despite appearing to serve a similar purpose. This raises the question of whether there is a proper use case for multi-provider in this scenario.