Hi, i'm a little bit confused about angular's behaviour on dependency injection and providers. But first i want to give you a short overview:
I'm new to Angular 2 and started just a few days ago with the Angular 2 tutorial. I also read a lot of docs in the meantime. I want to create an app which gets initialized by an initializer component. So i created the main AppComponent, the AppInitializerComponent and a SettingsService, which should later provide general settings, e.g. the title of the site. Now i tried to inject the Components / Services into their respective superordinate. What i would expect is, that the AppComponent knows about the AppInitializerComponent but not about the SettingsService, because it is only important for the AppInitializerComponent. But i can't get it working in a way like that. I ended up injecting both, the AppInitializerComponent and the SettingsService, into the AppComponent, but it doesn't feel good to me. You can take a look at my current working state here: https://plnkr.co/edit/ppEZRo2kharj8dJyBH6z I also made a plunker of my expected behaviour: https://plnkr.co/edit/4C7kburx8dxfn0locFYK What i would expect is, that i define the AppInitializerComponent as a @Component and give it a "providers" metadata attribute which contains the SettingsService. The code i would expect results in an error message saying that there is no provider defined for AppComponent -> AppInitializerComponent -> SettingsService. Is there any possibility in getting my expectation to work? Thanks a lot in advance :) Julian -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
