Skip to content
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

Error: StaticInjectorError(AppModule)[ModalGalleryComponent -> KeyboardService] #174

Closed
Bob19891212 opened this issue Dec 18, 2018 · 5 comments

Comments

@Bob19891212
Copy link

Hi:
I'm face this problem,when i use "ks-carousel" in my custom module, i will face this problem
"CarouselComponent.html:135 Error: StaticInjectorError(AppModule)[ModalGalleryComponent -> KeyboardService]"
when i use in root module(appmodule),it won't appear this issue

Angular CLI: 7.0.6
Node: 8.9.4
Angular:
...

Package Version

@angular-devkit/architect 0.10.6
@angular-devkit/core 7.0.6
@angular-devkit/schematics 7.0.6
@schematics/angular 7.0.6
@schematics/update 0.10.6
rxjs 6.3.3
typescript 3.1.6

@Ks89
Copy link
Owner

Ks89 commented Dec 18, 2018

So, if you add the module with forRoot() in your root module it's working, but not in your child module. Right?

Is your problem related to this issue #94?

PS: try to add more details to explain your situation

@Ks89
Copy link
Owner

Ks89 commented Dec 18, 2018

Also, did you check the official live example? https://stackblitz.com/edit/angular-modal-gallery-v7

@Bob19891212
Copy link
Author

Bob19891212 commented Dec 19, 2018

Yes, i add the module without forRoot() in child moule,
i do a test in stackblitz, https://stackblitz.com/edit/angular-axdjwp
you can see this issue in this test

@Ks89
Copy link
Owner

Ks89 commented Dec 19, 2018

What? forRoot in child module is wrong. This is a common pattern in Angular. Forroot() is only for the root module.
In your example I don't see any forRoot(). You aren't importing the module in your root module.

Please check my example carefully, because it's working and you can copy the configuration. It's also explained in the official documentation website.

@Bob19891212
Copy link
Author

you are right ,if i add the module with forRoot() in my child module,it works

Thanks

@Ks89 Ks89 closed this as completed Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants