You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Currently we have two main types of guards:
CanLoad: decides if we can load a module (used with lazy loading)
CanActivate and friends. It decides if we can activate/deactivate a route.
So we always decide where we want to navigate first ("recognize") and create a new router state snapshot. And only then we run guards to check if the navigation should be allowed.
This doesn't handle one very important use case where we want to decide where to navigate based on some data (e.g., who the user is).
I suggest to add a new guard that allows us to do that.
Here, navigating to '/home' will render `AdminHomePage' if the user is an admin and will render 'SimpleHomePage' otherwise. Note that the url will remain '/home'.
Implementation Notes
This should be handled in both applyRedirects and recognize.
@dylhunn I've considered sending the PR out as blocked by #45023 due to not wanting to have too many in-flight reviews. Our bigger projects have held up some of these smaller tasks. I think this feature may be more straightforward than #45023 so I'll try to get it out for 14.1
Activity
DzmitryShylovich commentedon Feb 15, 2017
Sounds similar to #12499
vicb commentedon Feb 15, 2017
Sounds good, what about
when:instead ofcanUse:?alexbyk commentedon Mar 16, 2017
Any progress on this feature?
itrethan commentedon Mar 31, 2017
LGTM, Approval
angular-robot commentedon Jun 4, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Jun 25, 2021
19 remaining items
atscott commentedon May 3, 2022
@dylhunn I've considered sending the PR out as blocked by #45023 due to not wanting to have too many in-flight reviews. Our bigger projects have held up some of these smaller tasks. I think this feature may be more straightforward than #45023 so I'll try to get it out for 14.1
feat(router): Add CanMatch guard to control whether a Route should match
angular-automatic-lock-bot commentedon Jul 14, 2022
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.