-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add canDeactivateChild guard #11836
Comments
+1, as canActivateChild, we have to deactivate child route. Is that possible without a new "canDeactivateChild guard"? Many thanks, |
Are there any news for this issue? Or are there any other solutions as @nlgi asked? |
Anything on this? I really wouldn't like to edit Ng2 from the inside, but that's what I've done so far. |
@fenderjair It seems the fix provided is fairly useful in some cases, just not in mine. What I want is to avoid any navigation while a custom popup is open, so I need to cover a big amount of routes. |
+1 Needed for lazyloaded routes |
+1 |
any news here ? this feature request is missing to fix my usecase. actually I have to specify
Actually, is there better way to avoid write it in every routes child? I mean handle all route deactivation and call my guard? |
are there any news or solution here? Please tell me about when will that be fixed? |
are there any news, solution or workarounds here? |
+2 |
+1. As of now any news on this issue? And BTW below is path i took to implement this as of now. Please suggest in case of any better Path Listening to valueChanges event of the NgForm and emitting an event from child component and subscribing it in parent to return proper value when Deactivate guard is fired. |
Why all of the downvotes without any reason as to why this functionality isn't needed? I actually have the exact same situation. I believe that I can use the canActivateChild at the root. This should prevent any route changes, right? |
The downvotes seem to be a response to '+1' comments which add nothing to the discussion vs adding a reaction to the original proposal, rather than a response to the proposal itself. |
Any solution ? |
Any workaround? |
Bump... This is really something that we need in order to create proper abstractions for large apps... In large app's having a guard definition per route doesn't scale... Having Thanks! |
Here is a detailed explanation why it is needed and how much it will help reducing code and boilerplate in large code base projects. |
As per the workaround
Should do the trick. But as per the feature request, Definitely a PLUS +1. Note here I did not use |
Also facing this problem right now. Any idea on the timeline for this? |
I now also face the same issue. The workaround is not acceptable in my case. Is there anything new? |
+1, but should tell, that i got some success with CanActivateChild in my project.
But i also thinks that calling canDeactivateChild will be more clear than checking if you can activate new route. It's just not clear to understand what will happen if you will prevent navigation by implementing CanActivateChild guard. |
There is another way to block pending navigations - You can override Location and write your own implementations of But i don't think it's matching answer to initial question... and not sure it's legal use of Location :| Anyway, successfully used this to block navigation events when some overlays presents on page. |
I also lost several hours because of this. Any news yet? |
this seems promising, not the full solution but covers some |
There are workarounds to this, but this is really a needed feature. |
I have been using the following workaround for a while with no problems that I'm aware of... The basic idea is to perform a pre-check every time a route is navigated, and manually intervene to ensure that the desired guards are in place. The example below will ensure that set up the logic in the root app.component constructor
global-route-guard.service.ts
|
this PR is to add `canDeactivateChild` to the route resolves angular#11836
this PR is to add `canDeactivateChild` to the route resolves angular#11836
this PR is to add `canDeactivateChild` to determine if the current user is allowed to deactivate a child of the root. resolves angular#11836
this PR is to add `canDeactivateChild` to determine if the current user is allowed to deactivate a child of the root. resolves angular#11836
this PR is to add `canDeactivateChild` to determine if the current user is allowed to deactivate a child of the root. resolves angular#11836
this PR is to add `canDeactivateChild` to determine if the current user is allowed to deactivate a child of the root. resolves angular#11836
I'm submitting a ... (check one with "x")
What is the motivation / use case for changing the behavior?
There is already a canActivateChild guard. Having the symmetric guard is equally important. Not sure why this wasn't added at the same time. We have many scenarios where we need to protect child routes from navigating away if they have pending unsaved changes. That's currently only possible by putting a canDeactivate guard on each child route.
The text was updated successfully, but these errors were encountered: