如何将字符串对象分配给observable <string>

时间:2019-04-12 10:38:53

标签: typescript

我正在尝试将可观察到的字符串转换为用于Firestore的纯字符串。

尝试过foreach方法

this.snapshot = this.task.snapshotChanges().pipe(
      tap(snap => {
        if (snap.bytesTransferred === snap.totalBytes) {
          // Update firestore on completion
          this.afs.collection('logos').add({ path, size: snap.totalBytes });
        }
      }),
      finalize(() => this.logoURL = this.storage.ref(path).getDownloadURL() )
this.logoURL.forEach(value => { this.imagePath = value.toString(); }

我想从logoUrl获取值并将其存储在imagePath中

谢谢

1 个答案:

答案 0 :(得分:0)

this.snapshot = this.task.snapshotChanges().pipe(
      tap(snap => {
        if (snap.bytesTransferred === snap.totalBytes) {
          // Update firestore on completion
          this.afs.collection('logos').add({ path, size: snap.totalBytes });
        }
      }),
      finalize(() => {
        this.logoURL = this.storage.ref(path).getDownloadURL();
        this.logoURL.subscribe(val => {
          this.imagePath = val;
        });
      })
    );