firebase - Firebase 5 Angular 5 AngularFireList.snapshotChanges() 错误
问题描述
当我尝试在 Angular 5/Firebase5 应用程序中订阅 AngularFireList 时,会出现以下错误。
zone.js:192 Uncaught TypeError: Object(...) is not a function
at SwitchMapSubscriber.eval [as project] (changes.js:7)
at SwitchMapSubscriber._next (switchMap.js:91)
at SwitchMapSubscriber.Subscriber.next (Subscriber.js:95)
at RefCountSubscriber.Subscriber._next (Subscriber.js:131)
at RefCountSubscriber.Subscriber.next (Subscriber.js:95)
at Subject.next (Subject.js:56)
at ConnectableSubscriber.Subscriber._next (Subscriber.js:131)
at ConnectableSubscriber.Subscriber.next (Subscriber.js:95)
at Notification.observe (Notification.js:32)
at AsyncAction.DelaySubscriber.dispatch (delay.js:91)
我的Service和Controller类内容如下,
1) 名为“FirebaseService”的服务
customers: AngularFireList<any>;
getCustomers(){
this.customers = this.fire.list('users');
return this.customers;
}
2) 控制器
constructor(private firebase: FirebaseService) { }
serviceProviders: ServiceProvider[];
var x = this.firebase.getServiceProviders();
x.snapshotChanges().subscribe(item => {
this.serviceProviders = [];
item.forEach(element => {
var y = element.payload.toJSON();
y["$key"] = element.key;
this.serviceProviders.push(y as ServiceProvider);
});
});
解决方案
AngularFire 的最新版本需要 rxjs 6。rxjs-compat
如果您有尚未升级的依赖项,请升级 rxjs 并包含。
推荐阅读
- node.js - 为什么即使指定的挂载路径不是它自己的,中间件也会被调用?
- r - 按部分字符串匹配分组
- android-management-api - 在 Android Management API Policy 中启用设备的相机应用
- php - 无法在 wamp 中登录 phpmysql 也与会话有关
- android - 在 Android Studio 3.6 中禁用 Gradle 离线模式
- c++ - 使用递归时如何在开头插入元素?
- android - 如何在 FirestoreRecyclerAdapter 中加载数据之前显示进度对话框
- list - 传递列表以在另一个视图中输出
- apache-kafka - KafkaRestProxy 多实例问题
- c++ - 通过默认字符串初始化向量中的字符串的简化