Return Observable in canDeactivate not working

前端 未结 3 1539
旧巷少年郎
旧巷少年郎 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:48

    It was not working on my end because I was using BehaviorSubject with initial value null.

    Make sure to create Observable from Subject like:

    private modalConfirmation = new Subject();
    public getModalSelectionObservable(): Observable {
        return this.modalConfirmation.asObservable();
    }
    

提交回复
热议问题