firebase - AngularFireStorage - 如何为项目列表设置 downloadURL
问题描述
我正在查询一个集合,其中的每个文档都有一个关联的图像。我使用的 angularfirestorage 片段在设置一个图像时效果很好,但是,当我有一个列表时,它们最终都会得到相同的图像。
如何确保每个文档中的每个图像在 HTML 中都有正确的绑定?
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>
解决方案
这有效:
代替
this.myPhoto = ref.getDownloadURL();
我用:
data.myPhoto = ref.getDownloadURL();
推荐阅读
- sql-server - 从 Salesforce 调用 SQL Server 存储过程需要什么?
- javascript - 有没有办法在页面上挂钩资源请求?
- azure-virtual-machine - 使用 Azure Bastion 远程访问 VNet Windows VM 的先决条件是什么?
- ruby-on-rails - 使用 webpack 开发服务器和 rails 服务器进行 Webpack 热重载
- c# - 从接口实现的不同类中调用方法
- regex - 获取某些特定区域的字符串
- flutter - 扑动应用程序的Firebase身份验证失败
- android - 基于用户通过google play game API玩的游戏数据可视化工具的可行性
- angular - 完成一个可观察的
- jekyll - Jekyll 和 Strapi:Strapi 服务器发送错误,状态如下:404。请确保它正确运行