I'm having some trouble understanding the logic that Angular2 uses when it comes to dependency injection. This is my situation:
app.component.ts:
import {Component} from 'angular2/core';
import {Demo1Service} from './demo-1.service';
@Component({
selector: 'app',
template: `<div>test template</div>`,
providers: [Demo1Service]
})
class AppComponent {
constructor(private _demo1Service: Demo1Service) {}
}
export {AppComponent};
demo-1.service.ts
import {Injectable} from 'angular2/core';
import {Data1Store} from './data-1.store';
@Injectable()
class Demo1Service {
constructor(private _data1Store: Data1Store) {}
};
export {Demo1Service};
data-1.store.ts
import {Injectable} from 'angular2/core';
@Injectable()
class Data1Store {}
export {Data1Store};
http://plnkr.co/edit/4aBNbAxtHbUvVqxPRUbv?p=preview
If you run this plunker you will see that Angular needs a provider for the Data1Store to be defined in the AppComponent. In order to have some separation of concerns, I would prefer that the AppComponent doesn't need to know about the existence of the Data1Store.
Is there something I'm here?