加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Firebase 5 Angular 5 AngularFireList.snapshotChanges()错误

发布时间:2020-12-17 17:57:30 所属栏目:安全 来源:网络整理
导读:当我尝试在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
当我尝试在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)

我的服务和控制器类内容如下,

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并包含rxjs-compat.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读