Angular2 fire没有导出成员'FirebaseListObservable'

时间:2017-10-04 12:21:00

标签: angular typescript firebase firebase-realtime-database

这是我的package.json

class Car(Model):
    id = UUIDField(primary_key=True,
                   default=uuid.uuid4,
                   editable=False)
    color = WordField(db_index=True, max_length=75)
    name = WordField(db_index=True, max_length=75)

在我的app模块中

"dependencies": {
    "@angular/cdk": "^2.0.0-beta.8",
    "@angular/common": "^4.3.4",
    "@angular/compiler": "^4.3.4",
    "@angular/core": "^4.3.4",
    ....//others


    "firebase": "^4.5.0",
    "angularfire2": "^5.0.0-rc.0",
},

 "peerDependencies": {
    "@angular/common": ">=2.3.1"
 },



 "devDependencies": {
  ..others
 "typescript": "~2.3.3",
 "webpack": "^3.6.0"
}

在我的组件中,我正在监听数据通道

export const firebaseConfig = {
   apiKey: "value",
   authDomain: "value",
   databaseURL: "value",
   projectId: "value",
   storageBucket: "value",
   messagingSenderId: "value"
};

"imports:[
   AngularFireModule.initializeApp(firebaseConfig), AngularFireDatabaseModule

]

每当我尝试使用import {AngularFireDatabase , FirebaseListObservable} from "angularfire2/database"; export class TrackingCenterComponent implements OnInit { registered: FirebaseListObservable<any>; constructor( private _af: AngularFireDatabase ) { this.registered = _af.list('/trucks'); } onSave(){ this.registered.push({ truckid: val,truckno:truckno, .......... }); } } nppm start进行编译时都会收到错误

ng serve

我不知道为什么和上周这种情况完美无缺。可能有什么不对。更新了我的npm软件包后,这个错误开始出现

我需要改变什么才能使其发挥作用。

注意:我通过Module '"/home/geowan/Desktop/apps/angular2/bcl/node_modules /angularfire2/database/index"' has no exported member 'FirebaseListObservable'.

安装了firebase

1 个答案:

答案 0 :(得分:-1)

您需要在应用组件中更改您的依赖关系,如下所示:

`import {AngularFireDatabase , FirebaseListObservable} from "angularfire2/database";`

`import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database-deprecated';`

它会起作用。