我不确定要为this.actions
返回的查询对象怎么做
this.actionCollection = this.db.collection('actions');
this.actions = this.actionCollection.ref.where('filterId', '==', this.filterId)
我应该怎么处理this.actions
?我尝试将其设置为我的视图,但出现此错误Error: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'
<h4>Actions List</h4>
<ul>
<li *ngFor="let action of actions | async">
{{action | json}}
</li>
</ul>
答案 0 :(得分:0)
您需要在其上调用 get
方法。这将返回 firebase.firestore.QuerySnapshot
类型的值。
它本质上是一个Promise
,因此您可以将then
方法链接到它来获取解析的数据。在这里,尝试一下:
this.actions = this.actionCollection.ref
.where('filterId', '==', this.filterId)
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
console.log(doc.id, " => ", doc.data());
});
});