我如何以反应形式检索可观察到的价值?

How i can retrieve value observable in reactiveform?

如何以反应形式检索我的 url 值?我不知道如何从 Observable 中提取值以由存在 Observable 的函数返回。我只需要从中返回一个值,没有别的。

uploadFile(event) {
    const file = event.target.files[0];
    const filePath = Date.now().toString();
    const fileRef = this.storage.ref('/referentiels/' + filePath);
    const task = this.storage.upload('/referentiels/' + filePath, file);
    this.uploadPercent = task.percentageChanges();
     task.snapshotChanges().pipe(
        finalize(() => {
       this.downloadURL = fileRef.getDownloadURL();
       this.downloadURL.subscribe((url) => {
            return url
        });
        }))
    .subscribe()
  }    
  onSaveReferentiel() {
    const nomSS = this.referentielForm.get('nomSS').value;
    const speSS = this.referentielForm.get('speSS').value;
    const webSS = this.referentielForm.get('webSS').value;
    const newReferentiel = new Referentiel (nomSS, speSS, webSS, ---url---);
    this.referentielsService.createNewReferentiel(newReferentiel);
    this.router.navigate(['/referentiels']); 
  }

试试这个

uploadFile(event) {
    const file = event.target.files[0];
    const filePath = Date.now().toString();
    const fileRef = this.storage.ref('/referentiels/' + filePath);
    const task = this.storage.upload('/referentiels/' + filePath, file);
    this.uploadPercent = task.percentageChanges();
   task.snapshotChanges().pipe(
    finalize(() => {
   this.downloadURL = fileRef.getDownloadURL();
   this.downloadURL.subscribe(url => this.url = url
    );

    }))
.subscribe())

}