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

NullInjectorError: No provider for CookieService! when trying to add it to an Angular library service and use the service in Project #650

Open
arifahmed4208 opened this issue Oct 18, 2023 · 0 comments
Labels

Comments

@arifahmed4208
Copy link

Describe the bug
Getting NullInjectorError when trying to add ngx-cookie to an Angular library service and use the service in Project

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom service in an Angular mono-repo library.
  2. Install this package in root.
  3. Inject cookie-service from CookieModule in your custom service as a DI.
  4. Add CookieModule as an import in your library module
  5. Expose your library module and your custom service via public-api.ts of your library.
  6. Build your library.
  7. Import your library module in your project's app-module
  8. Inject the custom service of your library wherever you want to use it in your project.
  9. ng-serve your project

Expected behavior
Application should run without any errors.

Stacktrace
If applicable, add stacktrace to help explain your problem.
Screenshot 2023-10-18 232803

Environment:

  • Angular version [15]
  • Browser [chrome,]
  • Version [118.0.5993.88]
  • OS: [e.g. windows]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant