salemdar / ngx-cookie

Implementation of Angular 1.x $cookies service to Angular 2
MIT License
318 stars 68 forks source link

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 11 months ago

arifahmed4208 commented 11 months ago

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: