Firebase AngularFireStorage-如何设置项目列表的下载URL
我正在查询一个集合,其中每个文档都有一个关联的图像。我使用的angularfirestorage片段在设置一个图像时效果很好,但是,当我有一个列表时,它们最终都是相同的图像 如何确保每个文档中的每个图像在HTML中具有正确的绑定Firebase AngularFireStorage-如何设置项目列表的下载URL,firebase,firebase-storage,angularfire2,Firebase,Firebase Storage,Angularfire2,我正在查询一个集合,其中每个文档都有一个关联的图像。我使用的angularfirestorage片段在设置一个图像时效果很好,但是,当我有一个列表时,它们最终都是相同的图像 如何确保每个文档中的每个图像在HTML中具有正确的绑定 myPhoto: Observable<string | null>; ... this.albums = this.albumCollection.snapshotChanges().pipe( map(actions => act
myPhoto: Observable<string | null>;
...
this.albums = this.albumCollection.snapshotChanges().pipe(
map(actions => actions.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
var image = myPhoto;
const ref = this.storage.ref(image);
this.myPhoto = ref.getDownloadURL();
return { id, ...data };
}))
);
<div [ngStyle]="{'background-image': 'url(' + (myPhoto | async) + ')'}"></div>
myPhoto:可见;
...
this.albums=this.albumCollection.snapshotChanges().pipe(
map(actions=>actions.map(a=>{
const data=a.payload.doc.data();
const id=a.payload.doc.id;
var image=myPhoto;
const ref=this.storage.ref(图像);
this.myPhoto=ref.getDownloadURL();
返回{id,…data};
}))
);
这起作用了:
而不是
this.myPhoto = ref.getDownloadURL();
我使用:
data.myPhoto = ref.getDownloadURL();