I'm learning Angular and currently trying to use the Firebase Authentication services. But I'm running into this error everytime I load the component that uses the service.
Error: Can't resolve all parameters for NgZone: (?).
at getUndecoratedInjectableFactory (core.mjs:11501:15)
at injectableDefOrInjectorDefFactory (core.mjs:11491:16)
at providerToFactory (core.mjs:11534:52)
at providerToRecord (core.mjs:11521:25)
at R3Injector.processProvider (core.mjs:11424:24)
at core.mjs:11410:56
at core.mjs:4167:76
at Array.forEach (<anonymous>)
at deepForEach (core.mjs:4167:11)
at R3Injector.processInjectorType (core.mjs:11410:13)
I inject it via to component like:
constructor(private operationService: OperationService,
private suscripctionService: SuscriptionService,
private fb: FormBuilder, private firebaseService: FirebaseService)
My FirebaseService is annotated with Injectable, and I import the services I need.
import { Injectable, Inject, forwardRef, NgZone } from '@angular/core';
import { UserFirebase } from '../_models/UserFirebase';
import * as auth from 'firebase/auth';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import {
AngularFirestore,
AngularFirestoreDocument,
} from '@angular/fire/compat/firestore';
import { Router } from '@angular/router';
@Injectable({
providedIn: 'root'
})
export class FirebaseService {
userData: any;
constructor(
private ngZone: NgZone,
private afs: AngularFirestore,
private afAuth: AngularFireAuth,
private router: Router
) {}
And in app.module.ts, in my providers array:
providers: [ AngularFireAuth, AngularFirestore, NgZone, FirebaseService ]
I know there are serveral questions like this asked, sadly I've not been able to solve my problem. I'm afraid this might be a circular dependency I'm missing.
Thanks for your time!
CodePudding user response:
I don't think you need to add NgZone to providers in app.module.ts ? Angular does it internally for you.