Ionic 4 : Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[AngularFireAuth -> InjectionToken angularfire2.app.options]


        Hi everyone, i started to learn Ionic Framework - ionic 4, actually it's powered with Angular 8 and ionic 4 let me easy and beautiful on html part. Somehow when i've working on create Firebase Authentication, it's broken after done with successful Authentication...


        Almost example i can prove that no one create best practice with custom case. So this thing happen, i'm not using FirebaseUI-Angular on the root or app component or main component, I've use on other new child component, here an error occurs.

Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[AngularFireAuth -> InjectionToken angularfire2.app.options]

        The point you should focus is AppModule, then AngularFireAuth, i've worry at the point of NullInjectorError that's the wrong place. Then the solution is go to file app.module.ts and add below import line.

import { environment } from '../environments/environment';
import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from '@angular/fire/auth';


Then inside @NgModule you must add as element into imports:[] all of them.

@NgModule({
    declarations: [AppComponent],
    entryComponents: [],
    imports: [
        BrowserModule,
        FormsModule,
        AngularFireModule.initializeApp(environment.firebaseConfig),
        AngularFireAuthModule,

        IonicModule.forRoot(),
        AppRoutingModule],
    providers: [
        StatusBar,
        SplashScreen,
        { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
    ],
    bootstrap: [AppComponent]
})

        After done above. Fully test by remove your account in Firebase console section Authentication, rerun your ionic with command line ionic serve and try login your site again, then this error Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[AngularFireAuth -> InjectionToken angularfire2.app.options]  should be gone.
Thank you so much for visit this blog. See U next thread. :)

No Like, No Thumbs Up, No Bell, Just support me by click ads, thank you... 

Comments

  1. I appreciate the effort of the author. I found it is an informative post on bootstrap technology. I hope you shared this kind of blog in future to help both the developer and business people.
    Hire Cake Php Programmer
    Hire Phonegap Developer
    Dedicated Wordpress Developer
    Hire Dedicated Laravel Developer
    Hire Cake Php Developer

    ReplyDelete

Post a Comment