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 Circular dependency when adding either HttpClient or HttpService to AuthenticationService #436

Closed
geekz-reno opened this issue Feb 8, 2019 · 5 comments
Assignees

Comments

@geekz-reno
Copy link

I'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.

image

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.

@geekz-reno geekz-reno changed the title Error Circular dependency when adding either **_HttpClient_** or **_HttpService_** to **AuthenticationService** Error Circular dependency when adding either HttpClient or HttpService to AuthenticationService Feb 8, 2019
@creal73 creal73 self-assigned this Feb 8, 2019
@creal73
Copy link
Collaborator

creal73 commented Feb 9, 2019

Have you tried with import { HttpClient } from '@angular/common/http'; or direct import of HttpService import { HttpService } from '../http/http.service'; ?

@geekz-reno
Copy link
Author

geekz-reno commented Feb 9, 2019

Hi @creal73, yes i already try both base on prev issue. Do i miss something? Coz i just generate new project and want to call my auth beckend.

For now its work if i use old http.

Thanks

@sinedied
Copy link
Member

sinedied commented Feb 9, 2019

See my answer to the same issue #432

@geekz-reno
Copy link
Author

Thanks @sinedied, will try this night.

@geekz-reno
Copy link
Author

@sinedied , @creal73 thanks for your help,

here my solution in case someone needed,

Create another service in my case MyAuthenticationService, and add to provider inside app.module

app.module,

image

my auth service,

image

and then you can use that service inside AuthenticationService

here is my AuthenticationService,

image

and be careful to use import from app/core or direct import service because it will make circular dependent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants