runGuardsAndResolvers documentation doesn’t clearly describe when it’s used
See original GitHub issueWhich @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
The Documentation suggests that you can supply a function to runGuardsAndResolvers . The link will take you to the documentation where it gives the type.
So I supplied the following and saw that not only was my route guard still being run, but the console log was not output.
((from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot) => {
console.log(from,to);
return false;
})
It seems something is not working as described in the documentation. So either it’s a bug or the documentation is misleading?
Please provide a link to a minimal reproduction of the bug
I don’t have time to do this. I’ll figure out another solution if needed.
Please provide the exception or error you saw
There were no errors. The guards ran when they should not have.
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 13.2.6
Node: 16.14.0
Package Manager: npm 8.3.1
OS: win32 x64
Angular: 13.2.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1302.6
@angular-devkit/build-angular 13.2.6
@angular-devkit/core 13.2.6
@angular-devkit/schematics 13.2.6
@angular/cdk 13.3.6
@angular/cli 13.2.6
@angular/flex-layout 13.0.0-beta.38
@angular/material 13.3.6
@schematics/angular 13.2.6
rxjs 7.5.5
typescript 4.5.5
Anything else?
I have seen runGuardsAndResolvers work in an older version of angular, but it was about a year and a half ago since I implemented that and it was for a different website.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
RunGuardsAndResolvers - Angular
Guards and/or resolvers will always run when a route is activated or deactivated. When a route is unchanged, the default behavior is the...
Read more >Angular resolver not updating or refetching data, despite ...
This is despite having the runGuardsAndResolvers property set to "always". My understanding is that this property should enable to functionality ...
Read more >Explore Angular Router's runGuardsAndResolvers | juri.dev
Learn how we can use new options introduced for the runGuardsAndResolvers setting for the Angular Router configuration to get a better control ...
Read more >How To Get Route Path Parameters In Non-Routed Angular ...
Even though it's bit hard to find, documentation clearly states that: ... null correctly describes value of the route path parameter which doesn't...
Read more >Tutorial: 9 - Routing & Multiple Views - AngularJS: API
The injector itself doesn't know anything about what the $http or $route ... the $routeProvider exposes APIs that allow you to define routes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is an issue with the documentation. RunGuardsAndResolvers only applies when the navigation doesn’t change the activated route. Probably would have been better named “rerunGuardsAndResolvers”.
That is, it applies only when they would otherwise not be run because the route isn’t being activated or deactivated.
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.