Regression routerNavigateByUrl + canLoad in 7.0-rc.0 <> 6.1 #26284
Labels
area: router
regression
Indicates than the issue relates to something that worked in a previous version
Milestone
I'm submitting a...
Current behavior
When calling
router.navigateUrl('/route').then(...)
in combination with acanLoad
guard that returns false, the Promise isn't getting resolved (then
function isn't getting invoked).Expected behavior
If this is the desired result, this is OK for me 😅
I just wanted to be sure of this, because this was working in v6.1
Minimal reproduction of the problem with instructions
There is a guard on the
lazy
route which returnsfalse
. When we click on the button it tries to navigate to the lazy loaded module guarded by acanLoad
guard.Notice that in v6.1 it logs
ok: false
whereas in v7.0 it does not.(After clicking it 3 times, the guard does return true).
Version 6.1: https://stackblitz.com/edit/load-guard-6?file=src%2Fapp%2Fapp.module.ts
Version 7.0-rc.0: https://stackblitz.com/edit/load-guard-7?file=src%2Fapp%2Fapp.module.ts
What is the motivation / use case for changing the behavior?
I encountered this while upgrading the NgRx repo to the rc version and encountered this issue in our tests - ngrx/platform#1354 (comment)
Environment
Others:
I'm not sure but I think this behavior comes from throwing an error at https://github.com/angular/angular/blob/master/packages/router/src/apply_redirects.ts#L90 but not catching it and dispatching a
NavigationCancel
event at https://github.com/angular/angular/blob/master/packages/router/src/router.ts#L410.The text was updated successfully, but these errors were encountered: