首页 文章

'{ query: { orderByChild: string; equalTo: string; }; }'类型的参数不能分配给'FirebaseListFactoryOpts'类型的参数

提问于
浏览
2

enter image description here
我'm trying to query a list from firebase but I'我收到此错误:

类型'{query:{orderByChild:string; equalTo:string; }; }'不能分配给'FirebaseListFactoryOpts'类型的参数 .

this.afDB.list('/category', {query: {
    orderByChild: "type",
    equalTo: "place"
}})

2 回答

  • 2

    感谢大家的帮助 .

    我正在导入弃用的,这是修复:

    import { AngularFireDatabase} from 'angularfire2/database';
    

    然后,只需按照angularfire2 documentation

    this.afDB.list('/category', ref => 
    ref.orderByChild('type').equalTo('place'))
    .valueChanges()
    .subscribe(categoryItems => {
      this.category = categoryItems;
      loadingPopup.dismiss()
    });
    
  • 1

    要向列表调用添加查询,可以使用传递回调而不是直接对象 . 有关列表查询文档,请参阅here .

    在你的情况下,你会想要类似的东西

    this.afDB.list('/category', ref => ref.orderByChild('type').equalTo('place'));
    

相关问题