Error Circular dependency when adding either HttpClient or HttpService to AuthenticationService
See original GitHub issueI’m submitting a…
[x] Bug report [ ] Feature request [ ] Documentation issue or request
Current behavior
Error Circular dependency when adding either HttpClient or HttpService to AuthenticationService
src\app\core\http\http.service.ts -> src\app\core\interceptors\error-handler.interceptor.ts -> src\app\core\index.ts -> src\app\core\core.module.ts -> src\app\core\http\http.service.ts
src\app\core\index.ts -> src\app\core\core.module.ts -> src\app\core\http\http.service.ts -> src\app\core\interceptors\error-handler.interceptor.ts -> src\app\core\index.ts
src\app\core\interceptors\error-handler.interceptor.ts -> src\app\core\index.ts -> src\app\core\core.module.ts -> src\app\core\http\http.service.ts -> src\app\core\interceptors\error-handler.interceptor.ts
Expected behavior
Success compile and can call from HttpClient or HttpService
Minimal reproduction of the problem with instructions
- Generate new project
ngx new
- Add HttpClient or HttpService to login function.
Environment
- generator version: 5.3.0
- node version: 8.11.3
- npm version: 6.7.0
- OS: Windows
Others: Same issue with:
generator work fine if i use Deprecated Http and i can’t use benefit of HttpService like cache.
Thank you for your great work at this generator.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
@sinedied , @creal73 thanks for your help,
here my solution in case someone needed,
Create another service in my case
MyAuthenticationService
, and add to provider insideapp.module
app.module,
my auth service,
and then you can use that service inside
AuthenticationService
here is my
AuthenticationService
,and be careful to use import from app/core or direct import service because it will make circular dependent.
See my answer to the same issue https://github.com/ngx-rocket/generator-ngx-rocket/issues/432