【发布时间】:2020-04-28 14:13:24
【问题描述】:
我有一个组件可以查询服务中的 angularfire 文档。下面的工作,因为我从另一个需要activatedRoute检查的函数中复制并粘贴了它。在这种情况下,我不需要激活的路线检查。
但是,我不确定删除该特定检查的语法,并且仍然具有查询数据库、获取结果并订阅它的相同结果。
Component.ts
testQuery(id: string) {
this._subscription = this._activatedRoute.params.pipe(
switchMap(params => {
return this.service.getInfo(id);
})
).subscribe(details => {
// Subscription stuff and form patchValue and behaviorSubject updates
})
}
Service.ts
getInfo(id: string): Observable<any[]> {
return this.afs.doc<any>(`collection/${id}`).valueChanges().pipe(shareReplay());
}
【问题讨论】:
标签: angular angularfire