-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependency injection in nested modules doesn't seem to work #10808
Comments
the
but there's a problem with the
|
I think I'm having the same issue trying to inject a singleton instance of a service class into the module being bootstrapped, like so:
This method is in boot.ts and gets called from javascript on an ASP.NET (cshtml) page to pass some values to the client app before it starts. Environment: Windows 10 Angular version: 2.0.0-rc.5 Browser: [Chrome 52] Language: [TypeScript tsc version 2.0.0] |
Don't know if my issue is related, but just in case. I was trying to extend Http class at the app level, but child injectors created via webpack-bundle + lazy route-loading were usually getting the super-class, even though I am not importing Http or HttpModule into any other module anywhere. I realize that's kind of vague, but it's the best I have time for atm. |
Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
I have an app module and modules for my sub components. In the ngDoBootstrap() of the main app module I initialize some shared services and give the created instance to the different sub components like so:
MyOtherModule is a simple wrapper for a component that just uses 'declarations' and 'bootstrap' to bootstrap a component. The component now crashes and says that there is no provider for MyService.
Expected/desired behavior
Since the component has no providers array it should look for a provider for MyService in the Module from which it was bootstrapped. Since the module has explicitly been given a provider for MyService, the component should get the instance sharedService when asking for a MyService.
Reproduction of the problem
A more verbose example is also listed here on stack:
http://stackoverflow.com/questions/38896842/migrating-conditional-boostrap-of-multiple-angular-apps-with-shared-services-to
Please tell us about your environment: MacOS El Capitan
The text was updated successfully, but these errors were encountered: