javascript-使用“ where()”时,在AngularFirestore中查询集合不会导致任何数据
作者:互联网
我有几个城镇的火力清单.该访问适用于:
public locations: Observable<any[]>;
constructor(db: AngularFirestore) {
this.locations = db.collection('/Locations').valueChanges();}
然后,我可以使用以下方法访问所有位置的数据:
{{ location.location_id }} etc
现在,我想在下一页访问一个特定城镇中的所有位置.
this.locationCollection = db.collection('/Locations', ref =>
ref.where('location_id', '==', 'Townname'));
但是它不是可分配的或_scalar.如果我将locationCollection更改为AngularFirestoreCollection,那么我不会收到任何错误,但也不会收到任何数据.如果我将类位置更改为接口,则它也是相同的.我什至试图
this.location = db.doc('/Locations/' + townname);
但是我无法访问属性或将请求记录到控制台.我觉得我浪费了太多的过时的教程.有人能指出我正确的方向吗,或者有人在MOST RECENT Firebase设置中有棱角英雄的例子吗?
解决方法:
试试这个
this.locationCollection = this.db.collection('Locations', ref => ref.where('location_id', '==', 'Townname')
并将其定义为
locations: Array<any>;
locationCollection: AngularFirestoreCollection<Location>;
其中位置是模型.
标签:angularfire2,angular,firebase,google-cloud-firestore,javascript 来源: https://codeday.me/bug/20191108/2008056.html