我收到一个错误,指出FirebaseListObservable没有导入的成员。此外,它说从"火力基地/应用程序"导入 * 作为火力基地;已声明但未使用。有什么方法可以解决此问题。
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { AngularFireAuth } from 'Angularfire2/auth';
import * as firebase from 'firebase/app';
import { AlertController } from 'ionic-angular';
import { Storage} from '@ionic/storage';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
@Injectable()
export class UserServiceProvider {
items: FirebaseListObservable<any>;
// this will be used to find out if a user has been loggged in then nav to another page
success: boolean;
constructor(private afAuth: AngularFireAuth, public alertCtrl: AlertController,
private storage: Storage, private fbDb: AngularFireDatabase) {
// This create a refrence to the users in the database
this.items = fbDb.list('/users')
}
FirebaseListObservable在更高版本的angularfire2中不再使用,请尝试改用AngularFireList:
import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
然后:
items: AngularFireList<any>;
如果您使用的是 Firebase 4.8.1,请尝试降级到 4.8.0:
npm install firebase@4.8.0
FirebaselistObservable 在最近的更新中未使用。
相反,您需要导入以下库:
import { Observable } from 'rxjs/Observable';
并将项目声明为:
items: Observable<firebase.User>;
上述实现将解决您的错误