I have 3 services:
auth.service.ts, account.service.ts, http.service.ts
While user signup I should create new account therefore
You can use Injector
for this. Inject it via constructor as usual, and then when you will need some service that leads to the circular dependency, get that service from it.
class HttpService {
constructor(private injector: Injector) { }
doSomething() {
const auth = this.injector.get(AuthService);
// use auth as usual
}
}
@deprecated from v4.0.0 use Type or InjectionToken
const auth = this.injector.get(AuthService);
Works on Angular 10:
const AuthService = this.injector.get<AuthService>(AuthService);