Skip to content

Router: CanDeactivate doesn't provide future RouterState snapshot  #10186

Closed

Description

@brandonroberts

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When using the CanDeactivate guard, the RouterStateSnapshot is a snapshot of the current state.

Expected/desired behavior

The RouterStateSnapshot in the canDeactivate(component, route, state) should provide the state as the future RouterState.

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).

http://plnkr.co/edit/8SBz5eKZOBh1vuFiNWtW?p=preview

  1. Open the developer console
  2. Click on the Away link
  3. Click on the Home link
  4. Note the console logs destination url: /away from the RouterStateSnapshot.url

What is the expected behavior?

The console logs destination url: / from the RouterStateSnapshot.url

What is the motivation / use case for changing the behavior?

To provide some context as to the proposed destination URL and other information. The current RouterState is already available through the Router service

Please tell us about your environment:

  • Angular version: 2.0.0-rc.X
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5 | Dart]

cc: @vsavkin

Activity

  1. zoechi commented on Jul 20, 2016

    @zoechi
    Contributor

    like #9853 ?

  2. brandonroberts commented on Jul 20, 2016

    @brandonroberts
    ContributorAuthor

    Yea, I'm not proposing adding another argument to the method though. I'll leave a comment there

  3. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    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.

  4. locked and limited conversation to collaborators on Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions