snapshotChanges()在“角度”对话框中不起作用

时间:2019-11-09 00:06:06

标签: angular firebase google-cloud-firestore

我使用file-upload.component.ts,当在另一个组件中用作子组件时,它工作正常,但是在对话框中(作为子组件)使用时,它无法按预期工作。

startUpload(event: FileList) {

    const file = event.item(0);
    const ref = this.storage.ref(this.imagePath);
    this.task = this.storage.upload(this.imagePath, file);

    // snapshotChanges() doesn't complete in Angular material dialog.
    this.snapshot = this.task.snapshotChanges().pipe( 
      finalize(async () => {
        this.downloadURL = await ref.getDownloadURL().toPromise();
      })
    );

}

该文件已上传到Firebase存储,但是snapshotChanges()无法运行,并且我没有任何下载URL。

0 个答案:

没有答案