我有几个城镇的火力基地位置列表。该访问适用于:
public locations: Observable<any[]>;
constructor(db: AngularFirestore) {
this.locations = db.collection('/Locations').valueChanges();}
Run Code Online (Sandbox Code Playgroud)
然后我可以通过以下方式访问所有位置的数据:
{{ location.location_id }} etc
Run Code Online (Sandbox Code Playgroud)
现在我想在下一页中访问一个特定城镇的所有位置。
this.locationCollection = db.collection('/Locations', ref =>
ref.where('location_id', '==', 'Townname'));
Run Code Online (Sandbox Code Playgroud)
但它不可分配或_标量。如果我将 locationCollection 更改为 AngularFirestoreCollection 那么我不会得到任何错误,但也没有数据。如果我将类位置更改为接口,它也是一样的。我什至试图得到
this.location = db.doc('/Locations/' + townname);
Run Code Online (Sandbox Code Playgroud)
但我无法访问属性或将请求记录到控制台。我觉得我在太多过时的教程上浪费了时间。有人能指出我正确的方向吗?或者有人有带有最新 Firebase 设置的角度英雄示例吗?
javascript firebase angularfire2 angular google-cloud-firestore