Javascript 带有可观察对象的AngularFire2未捕获$ref属性

Javascript 带有可观察对象的AngularFire2未捕获$ref属性,javascript,angular,firebase-realtime-database,rxjs,angularfire2,Javascript,Angular,Firebase Realtime Database,Rxjs,Angularfire2,因此,我开始使用AngularFire2版本4.0.0-rc.1,并坚持解决这个问题: getWishlist$(): FirebaseListObservable<{}> { return <FirebaseListObservable<{}>>this.store.select(getFirebaseUID) .filter(res => res.isAuthenticated) .map(res => re

因此,我开始使用AngularFire2版本4.0.0-rc.1,并坚持解决这个问题:

  getWishlist$(): FirebaseListObservable<{}> {
    return <FirebaseListObservable<{}>>this.store.select(getFirebaseUID)
      .filter(res => res.isAuthenticated)
      .map(res => res.UserUUID)
      .switchMap(uid => this.db.list(`/wishlist/${uid}/products`));
  }
错误是:

Cannot read property 'orderByChild' of undefined

我做错了什么?

我回答了一个类似的问题,这个问题是通过

一般来说,switchMap和RxJS不是这样工作的。运算符返回的可观测值取决于调用运算符的可观测值。所述可观察实例可以实现为返回相同类型的可观察实例

AngularFire2可观测执行提升-请参见和-但这与您描述的情况没有区别


从switchMap调用返回的可观察对象是从this.store.select中提取的可观察对象,而不是从this.db.list中提取的可观察对象。

因此,请将我的问题扩展到您提供的链接。若我调用.switch操作符,但它并没有改变任何情况,$ref仍然是未定义的,因为我从来并没有这样做过。对吗?所以对我来说,最好是让.map订阅,接收FirebaseList/ObjectObservable,并将其绑定到组件类(如果我理解正确的话)。这有点悲哀,因为我希望在服务中有更多的逻辑……如果没有呼叫订阅,什么都不会发生。如果您查看原始的getWishlist$方法,应该很清楚,如果没有subscribe,它将无法工作,因为它正在从store observable获取UID,并使用该UID通过AngularFire2列表间接创建Firebase引用,因此返回值不可能是包含引用的对象。
Cannot read property 'orderByChild' of undefined