【问题标题】:AngularFireStorage - How to set the downloadURL for a list of itemsAngularFireStorage - 如何为项目列表设置 downloadURL
【发布时间】:2018-12-19 16:52:59
【问题描述】:

我正在查询一个集合,其中的每个文档都有一个关联的图像。我使用的 angularfirestorage sn-p 在设置一个图像时效果很好,但是,当我有一个列表时,它们最终都会得到相同的图像。

如何确保每个文档中的每个图像在 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>

【问题讨论】:

    标签: firebase firebase-storage angularfire2


    【解决方案1】:

    这行得通:

    而不是

    this.myPhoto = ref.getDownloadURL();
    

    我用:

    data.myPhoto = ref.getDownloadURL();
    

    【讨论】:

      猜你喜欢
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 2020-09-29
      • 1970-01-01
      • 1970-01-01
      • 2020-12-15
      • 1970-01-01
      相关资源
      最近更新 更多