Vinz and Tonz
Vinz and Tonz

Reputation: 3587

Navigating to the same route cancelled by the canDeactivate guard is failing

If i try to navigate to a route that is cancelled by the canDeactivate guard, its not happening . Is their any workaround for this issue ?

I have a component with a form and if their are any unsaved changes and if we try to navigate away, we are showing a bootstrap confirm popup in the canDeactivate guard. If we select OK then we navigate to that same route again, which is not happening. Is their any workaround for this issue ?

Upvotes: 1

Views: 837

Answers (2)

fatslug
fatslug

Reputation: 127

Just spent 3 hours trying to figure this out for myself. It's a bug with @angular/router version 3.2.

I fixed it by downgrading to version 3.1 and reinstalling the package.

Hope this helps.

Upvotes: 1

Avnesh Shakya
Avnesh Shakya

Reputation: 3906

I am not sure how you are trying, but checkout this:

canDeactivate() {
  return dialogService.confirm('Discard unsaved changes?');
}

This should work for you. Check out this Doc

Upvotes: 0

Related Questions