Questions tagged [candeactivate]

39 questions
1
vote
0 answers

ion-back-button does not work correctly with canDeactivate guard

My Ionic 5 application has the following 3 pages with the navigation path HomePage -> UserPage (with canDeactivate guard) -> SharePage UserPage canDeactivate method: canDeactivate() { const alert = await this.alertCtrl.create({ …
1
vote
0 answers

How to deal with dynamic components and router outlet?

Let's consider component structure: appComponent > router-outlet (A, B, C) > a, b, c (According to selected one), where: A, B, C: Load dynamically a, b, c (dynamic component loaders) a, b, c: Dynamic loaded components The purpose of this excercise…
1
vote
1 answer

Dynamic canDeactivate Guard: Show confirm message before navigating away from form with changes

I'm working on a project with lot of forms pages, I want to give intimation to the end-user whenever they try to navigate to another route without saving their changes. In all the pages I'm using reactive forms something like this this.mainForm =…
Arjun
  • 547
  • 2
  • 6
  • 23
0
votes
2 answers

Confirmation pop up when user leaves page vs closes browser/tab

currently when the user leaves the page I use the beforeunload event to show the default browser popup. But I don't want this popup when the user navigates to another page or so on. I have a canDeactivate guard with a custom popup and a custom…
Mush-A
  • 435
  • 3
  • 11
0
votes
0 answers

CanDeactivate custom confirm message not working properly

I've been facing problem with custom dialog confirmation about losing data in my app. I tried 2 approaches. First one results in dialog oppening and all the background elements disappear, but besides that everything works. Second approach results…
Kacper
  • 1
  • 1
0
votes
0 answers

Prevent leaving app with canDeactivate and intermediate page

To my angular app I added Redirect page which is opening first by routing. This page have only one purpose - redirect to home page (this.router.navigate(['home']);). To home page I added guard canDeactivate which is checking if nextRoute is redirect…
0
votes
1 answer

How to make CanDeactivate work with kendo-ui angular dialog

I'm trying to implement this CanDeactivate Route Guard using kendo-ui angular dialog instead of the window.confirm, It works fine with window.confirm but with kendo-ui dialog only the second time I execute the dialog. The first time the method…
ZotNet
  • 35
  • 6
0
votes
0 answers

when user click logout button that time candeactivate automatic call and show after logout popup can you leave this page

I want to code when user click On logout button candeactivate automatically call to.. after that logout want to show logout popup which is "can you leave this page" import { CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from…
Solution
  • 1
  • 1
0
votes
0 answers

Handling browser refresh using a guard service

This is regarding the question here and the solution answered by @Stewdebaker. How can I stop the browser pop and add my custom pop-up using the same guard service which is provided by the author mentioned above? I tried returning true from the…
0
votes
0 answers

Angular canDeactivate route material dialog not navigating away from page

Everything is working as expected, except for when the user selects "Yes, Leave" button on modal window. After clicking the "Yes, Leave" button, it closes modal window and does not navigate away to the new…
Jason Spence
  • 472
  • 5
  • 16
0
votes
1 answer

Angular 11: Make canDeactivate observable wait for nested function

I'm trying to replace my browser alert with a custom one using Material dialog. If the user tries to navigate away from the form with unsaved changes, the custom alert shows. But I need to wait (pause the function) until the user clicks an option to…
0
votes
1 answer

How to parse data from component into Guard in Angular

I want to show a prompt on screen to the user if they are trying to navigate away from a page in which they have made changes to a form. I have created a Guard so far, and successfully got it to log something in the console when the user navigates…
0
votes
2 answers

Angular CanDeactivate Guard Not Working Properly With MatDialog

I've created a route guard with CanDeactivate that determines if a user can navigate away from a page if they have any unsaved changes, and triggers a MatDialog modal if any unsaved changes exist. I've looked at plenty of guides and similar threads…
0
votes
1 answer

CanDeactivate Not Firing in iFrame

I have an application which has an iframe into a separate Angular application. The src of the iframe is to a component. Long story short, the Angular app has to redirect to the home page, then back to the component in the src. If I use my back…
ScubaSteve
  • 7,724
  • 8
  • 52
  • 65
0
votes
2 answers

canDeactive | observable keeps its initial value

Example seen by this example This is my canDeactivate Guard: export interface CanComponentDeactivate { canDeactivate: () => Observable | Promise | boolean; } @Injectable() export class CanDeactivateGuard implements…
Iraklis Bekiaris
  • 1,163
  • 15
  • 43