【发布时间】:2022-01-01 21:29:53
【问题描述】:
我想通过仅过滤掉具有特定 ID 的文档来查询项目集合。
import { Firestore, collectionData, collection } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
interface Item {
name: string,
...
};
@Component({
selector: 'app-root',
template: `
<ul>
<li *ngFor="let item of item$ | async">
{{ item.name }}
</li>
</ul>
`
})
export class AppComponent {
item$: Observable<Item[]>;
constructor(firestore: Firestore) {
const collection = collection(firestore, 'items');
this.item$ = collectionData(collection);
}
}
【问题讨论】:
-
你能提供一个我们可以复制的示例代码吗?我发现这个Github link 可能对你有帮助。
-
你能做到吗?
-
@AlbertoEspinoza 请检查我刚刚发布的答案,希望它有助于解决您的问题。
标签: javascript angular google-cloud-firestore