Return Observable in canDeactivate not working

前端 未结 3 1538
旧巷少年郎
旧巷少年郎 2020-12-18 02:59

I have a confirm/cancel modal dialog that pops up when a user leaves a route. I do this by using a guard with the canDeactivate method. However I want canDeactivate to wait

3条回答
  •  情话喂你
    2020-12-18 03:21

    Use take(1) or first() (don't forget to import)

    return this.formService.getModalSelectionObservable().first();
    

    to ensure the observable is closed after the first event, otherwise the router will wait until it is closed from the service.

提交回复
热议问题