angularfire: ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AuthModule)[AuthService -> AuthService -> AngularFirestore -> InjectionToken
Angular: 13.0.3
Firebase: 9.4.0
AngularFire: 7.2.0
After upgrade angularfire 6 to 7 i got error
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AuthModule)[AuthService -> AuthService -> AngularFirestore -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]
simple if i can it any component constructor
private firebaseAuth: AngularFireAuth,
or
private angularFirestore: AngularFirestore,
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 19
Hi! This works for me. I put this in app.module.ts
import { FIREBASE_OPTIONS } from ‘@angular/fire/compat’;
@NgModule({ … providers: [ { provide: FIREBASE_OPTIONS, useValue: environment.firebaseConfig } ], })
I see this pretty chaotic. The samples are so out of date and one cannot really follow them. I am getting the same errors.
I was able to initialize my module like this, and I try to stay our of compact/ package as it gives tons of errors.
I am not really sure which API or which documentation should I follow
https://github.com/angular/angularfire/blob/master/site/src/auth/route-guards.md or https://github.com/angular/angularfire/blob/master/docs/auth/router-guards.md
If I use the one from /site/ then it is also out of sync with latest code as this import is invalid.
Hi, I had same problem, I solved adding AngularFireModule.initializeApp(environment.firebaseConfig) into imports of AppModule
import { AngularFireModule } from ‘@angular/fire/compat’; import { environment } from ‘src/environments/environment’;
@NgModule({ declarations: [AppComponent], imports: [ AppRoutingModule, BrowserModule, AngularFireModule.initializeApp(environment.firebaseConfig), ], providers: […], bootstrap: [AppComponent], })
Same here! I use a config generated by @angular/fire schematic:
I get the same error
You need to import the old module as a work around, “AngularFireModule.initializeApp(environment.firebase)”
you need to declare the providers :
although my AuthService has the following meta data
I dont know why its is not working