携带Firestore文件的正确方法是什么?我有一个接收文档ID的子组件。
我尝试了以下操作但没有结果:
component.service
getPaquete(id: string) {
return this.afs.doc('paquetes2/' + id).valueChanges();
}
component.ts
@Input() idPaquete: any;
paquete;
ngOnInit() {
this.fs.getPaquete(this.idPaquete).subscribe( res => {
this.paquete = res;
console.log(this.idPaquete); // In console I get the ID: FXjRvjJ9qNFkVeX6QXIa
console.log(this.paquete); // In console I get: Undefined
});
}
component.html
<p class="h5">{{paquete.nombrePaquete}}</p>