Skip to content
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

prevent navigation from nested component #8722

Closed
bluEEil opened this issue May 19, 2016 · 7 comments
Closed

prevent navigation from nested component #8722

bluEEil opened this issue May 19, 2016 · 7 comments

Comments

@bluEEil
Copy link

bluEEil commented May 19, 2016

have a component which is set to a be inserted in some route. I want to write another more general component, that I can place in that first component and will prompt the user when he trys to navigate away from the first component route and ask him if he is sure he wants to leave

I tried to use CanDeactivate in this Leave Dialog component but it is never being called (when switching routes).

Steps to reproduce and a minimal demo of the problem
I have asked a question about this in stack over flow with more explanation and a code sample:
[http://stackoverflow.com/questions/37118511/prevent-navigation-from-nested-component-in-angular-2](prevent navigation from nested component)

Current behavior
The routerCanDeactivate method isn't called in the nested component and only in the root component of the route when the user tries to navigate away.

Expected/desired behavior
The routerCanDeactivate method should be called in the nested component as well so they can prevent navigation if needed

Other information
If there is a different way to achieve this behavior that Im not aware of then this might not be an issue.

@zoechi
Copy link
Contributor

zoechi commented May 23, 2016

What Angular2 version, what Router version router of Angular2 RC.1 or router-deprecated?
In the new router CanDeactivate was just implemented (not yet released) #8477

@bluEEil
Copy link
Author

bluEEil commented May 23, 2016

Angular 2.0.0-beta.6
How can I tell about the router version? I dont see it in my package.json

@zoechi
Copy link
Contributor

zoechi commented May 23, 2016

In beta.6 there is only one version. Since RC.0 there are two (the one already in beta.6 and a new one). #8477 is about the new one. I don't expect fixes for the old one anymore.

@bluEEil
Copy link
Author

bluEEil commented May 23, 2016

So this should be fixed by updating my version?

@zoechi
Copy link
Contributor

zoechi commented May 23, 2016

Nope - "(not yet released)". Probably when Angular2 RC.2 is released. You'd also need to migrate to the new router.

@IgorMinar
Copy link
Contributor

This issue was made obsolete by router v3: https://angularjs.blogspot.com/2016/06/improvements-coming-for-routing-in.html

This particular feature is available in router v3.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants