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

fix(router): canLoad should cancel a navigation instead of failing it #11001

Merged

Conversation

vsavkin
Copy link
Contributor

@vsavkin vsavkin commented Aug 23, 2016

Currently canLoad returning false fails a navigation instead of canceling it. This is different from canActivate.

This PR changes it so canLoad behaves similar to canActivate.

@vsavkin vsavkin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 23, 2016
@naomiblack
Copy link
Contributor

this addresses part of the concern in #10585

@naomiblack naomiblack added this to the 2.0.0-rc.6 milestone Aug 23, 2016
@@ -22,3 +22,12 @@ export const PRIMARY_OUTLET = 'primary';
export type Params = {
[key: string]: any
};

export class ErrorCancelingNavigation extends Error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NavigationCancelingError sounds like a better name

@IgorMinar
Copy link
Contributor

public api spec needs to be updated

@IgorMinar IgorMinar added pr_state: LGTM action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 23, 2016
@vsavkin vsavkin force-pushed the can_load_should_work_as_as_can_activate branch from 12c5c3e to 786487f Compare August 24, 2016 15:56
@vsavkin vsavkin added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Aug 24, 2016
@kara kara merged commit f1ce760 into angular:master Aug 24, 2016
@YeomansIII
Copy link

I'm still receiving this error when returning false from canLoad. Is this related?

Uncaught (in promise) Error: NavigationCancelingError: Cannot load children because the guard of the route "path: ''" returned false

Returning false in canLoad should not return an error.

@IgorMinar
Copy link
Contributor

IgorMinar commented Dec 15, 2017 via email

@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 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants