-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Component: DynamicDialog NullInjectorError: No provider for NameService! #14730
Comments
Might be related to #14491 |
@mehmetcetin01140 @cetincakiroglu any update on this? |
Hi, After the investigation, we've found the issue caused by injection level difference. You're providing dialogService in the component level and demoService in the module level. Because of this, dialogService fails to find and inject DemoService. It works as expected if both of them are provided at the same level. That's why injecting the DemoService to the component.ts makes it work. Please see the example: https://stackblitz.com/edit/7qkchf-expefk?file=src%2Fapp%2Fdemo%2Fdemo.module.ts To provide a better guide, we'll update the documentation of DynamicDialog and mention this use. Thanks a lot for reporting the issue! |
Thanks a lot, that indeed solves the issue |
Describe the bug
Having a module with a service in providers array. Create a parent component that opens a dialog component with a child component that uses the service provided in the module, gives NullInjectorError instead of inheriting the service instance from the module.
Environment
Primeng 17.5
Reproducer
https://stackblitz.com/edit/7qkchf?file=src%2Fapp%2Fdemo%2Fdynamic-dialog-example-demo.ts,src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fdemo%2Fdemo.service.ts,src%2Fapp%2Fdemo%2Fdemo.module.ts,src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fdemo%2Fdynamic-dialog-example-demo.html,src%2Findex.html,src%2Fapp%2Fdemo%2Ftest-child.component.ts,src%2Fapp%2Fdemo%2Fdialog.component.ts,src%2Fapp%2Fdemo%2Fdynamic-dialog-example-demo.scss
Angular version
17.0.5
PrimeNG version
17.5
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.18.0
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
The child component should use the instance from the module providers array. Was working in v15 and prior
The text was updated successfully, but these errors were encountered: