【发布时间】:2021-06-07 14:30:21
【问题描述】:
我正在尝试从 Firestore 获取数据,以显示在编辑组件模板中。我收到一条错误消息,提示“‘Observable’类型缺少‘Agency’类型的以下属性:agencyId、benefitCardName、benefitCardPhotoUrl、logoUrl 和另外 3 个。” 我的组件:
agency$: Agency;
this.agency$ = this.activatedRoute.paramMap.pipe(switchMap(params => this.afs.collection<Agency>('agencies').doc<Agency>(`${params.get('agencyId')}`)
.valueChanges().pipe(map( (data: Agency) =>
{
this.name = data.name,
this.phone = data.phone;
}))));
console.log(this.agency$);
我的界面
export interface Agency {
agencyId: Promise<string>;
benefitCardName: string;
benefitCardPhotoUrl: Promise<string>;
logoUrl: Promise<string>;
name: string;
phone: string;
pocTimesheetRequired: boolean;
}
【问题讨论】:
标签: angular typescript google-cloud-firestore