No provider for AngularFireDatabase, AngularFireAuth

后端 未结 6 2073
不思量自难忘°
不思量自难忘° 2020-11-29 05:12

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,

6条回答
  •  眼角桃花
    2020-11-29 05:51

    Inside app.module.ts add below:

    import { AngularFireModule } from 'angularfire2';
    
    import { AngularFireDatabaseModule } from 'angularfire2/database';
    

    Then import as below:

    @NgModule({
      declarations: [
        MyApp,
        HomePage
      ],
      imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp),
        AngularFireModule.initializeApp(firebaseConfig),
        AngularFireDatabaseModule
      ],
    

    Inside home.ts use as below:

    import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
    
    items: FirebaseListObservable;
    
      constructor(public navCtrl: NavController, db: AngularFireDatabase) {
            this.items = db.list('/items');
      }
    

    My Ionic info:

    Ionic Framework: 3.1.1
    Ionic App Scripts: 1.3.7
    Angular Core: 4.0.2
    Angular Compiler CLI: 4.0.2
    Node: 6.10.1
    OS Platform: macOS Sierra
    

提交回复
热议问题