-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Closed
Labels
area: routerfeatureIssue that requests a new featureIssue that requests a new featurefeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under consideration
Milestone
Description
I'm submitting a ... (check one with "x")
[ ] 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.
[
{path: 'home', component: AdminHomePage, canUse: [IsAdmin]},
{path: 'home', component: SimpleHomePage}
]
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.
fjozsef, alexbyk, royling, caroso1222, adharris and 27 more
Metadata
Metadata
Assignees
Labels
area: routerfeatureIssue that requests a new featureIssue that requests a new featurefeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under consideration