找不到模块“ angularfire2 /数据库”

时间:2018-07-05 17:35:14

标签: angularjs firebase ionic-framework firebase-realtime-database ionic3

运行时错误 找不到模块“ angularfire2 /数据库” 堆 错误:找不到模块“ angularfire2 /数据库”

Home.Ts

  import { Component } from '@angular/core';
 import { NavController } from 'ionic-angular';
 import { FirebaseProvider } from      './../../providers/firebase/firebase';
 //error
 import { FirebaseListObservable } from 'angularfire2/database';

 @Component({
   selector: 'page-home',
   templateUrl: 'home.html'
 })
 export class HomePage {
   shoppingItems: FirebaseListObservable<any[]>;
   newItem = '';
   constructor(public navCtrl: NavController, public firebaseProvider:      FirebaseProvider) {

     this.shoppingItems = this.firebaseProvider.getShoppingItems();
   }
   addItem() {
     this.firebaseProvider.addItem(this.newItem);
   }
   removeItem(id) {
     this.firebaseProvider.removeItem(id);
   }
 }

此行中有错误

  import { FirebaseListObservable } from 'angularfire2/database';

app.module.Ts

 import { BrowserModule } from '@angular/platform-browser';
 import { ErrorHandler, NgModule } from '@angular/core';
 import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

 import { MyApp } from './app.component';
 import { HomePage } from '../pages/home/home';
 import { ListPage } from '../pages/list/list';

 import { StatusBar } from '@ionic-native/status-bar';
 import { SplashScreen } from '@ionic-native/splash-screen';

 import { HttpModule } from '@angular/http';
 import { AngularFireDatabaseModule } from 'angularfire2/database';
 import { AngularFireModule } from 'angularfire2';

 import { FirebaseProvider } from '../providers/firebase/firebase';

 const firebaseConfig = {
   apiKey: "$$$$$$$$$",
   authDomain: "44444444.firebaseapp.com",
   databaseURL: "https://44444.firebaseio.com",
   projectId: "44444",
   storageBucket: "i4444[enter image description here]     [1]3.appspot.com",
   messagingSenderId: "************"
 };

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

   ],
   bootstrap: [IonicApp],
   entryComponents: [
     MyApp,
     HomePage,
     ListPage
   ],
 providers: [
   StatusBar,
  SplashScreen,
 {provide: ErrorHandler, useClass: IonicErrorHandler},
 FirebaseProvider
]
   })
 export class AppModule {}'

输出:

运行时错误 找不到模块“ angularfire2 /数据库” 堆 错误:在Object.195(http://localhost:8100/build/main.js:89:7)at webpack_require http://localhost:8100/build/vendor.js:55:30)at Object.194(http://localhost:8100/build/main.js:44:87

上找不到模块“ angularfire2 / database”

1 个答案:

答案 0 :(得分:0)

尝试

import { AngularFireList } from 'angularfire2/database';

代替

import { FirebaseListObservable } from 'angularfire2/database';

您使用哪个版本?在AngularFire 5.0中,FirebaseListObservable已删除