No provider for AngularFireDatabase, AngularFireAuth

Slabach picture Slabach · May 4, 2017 · Viewed 44.4k times · Source

Apologies as I can't think of a better way of including all the information... When I run this, I get an error saying the following. I've followed the Ionic Docs to the T, I can't figure out what could possibly be wrong.

Error:

No provider for AngularFireDatabase!

Error

Package.json Package

App.module.ts App.Module

Home.html Home HTML

Home.ts Home TS

Answer

Pengyy picture Pengyy · May 4, 2017

AngularDatabase(same for AngularAuth) is separated to its own module AngularFireDatabaseModule(AngularFireAuthModule for AngularAuth) from version [email protected], see documentation here.

you should import AngularFireDatabaseModule(AngularFireAuthModule for Authentication) in your RootModule.

import { AngularFireModule } from 'angularfire2';
// for AngularFireDatabase
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireDatabase, FirebaseObjectObservable } from 'angularfire2/database';
// for AngularFireAuth
import { AngularFireAuthModule } from 'angularfire2/auth';
import { AngularFireAuth } from 'angularfire2/auth';

@NgModule({
  imports: [
    AngularFireModule.initializeApp({         <---- main module
      apiKey: ...,
      authDomain: '...',
      databaseURL: '...',
      storageBucket: '...',
      messagingSenderId: '...'
    }),                                       
    AngularFireDatabaseModule,                <---- for database 
    AngularFireAuthModule                     <---- for auth
  ]
})