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
{{ message }}
Repository navigation
Commit 8735af0
Browse filesBrowse the repository at this point in the historyBrowse files
feat(router): Add ability to return UrlTree with NavigationBehaviorOptions from guards (#45023)
Returning `UrlTree` from a guard was a convenient new feature added to
the `Router`. However, it does not have feature-parity with the old
`router.navigate(...); return false;` pattern. The most common use-case
for this feature is to redirect to a new page _without_ updating the URL
from the initially attempted navigation. For example, rendering a 404
page when the user does not have access privelages to a route.
Fixes#17004Fixes#27148
BREAKING CHANGE: Guards can now return `RedirectCommand` for redirects
in addition to `UrlTree`. Code which expects only `boolean` or `UrlTree`
values in `Route` types will need to be adjusted.
PR Close#45023
Copy file name to clipboardExpand all lines: adev/src/content/guide/routing/router-reference.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,7 +170,7 @@ These events are shown in the following table.
170
170
|[`ChildActivationEnd`](api/router/ChildActivationEnd)| Triggered when the Router finishes activating a route's children. |
171
171
|[`ActivationEnd`](api/router/ActivationEnd)| Triggered when the Router finishes activating a route. |
172
172
|[`NavigationEnd`](api/router/NavigationEnd)| Triggered when navigation ends successfully. |
173
-
|[`NavigationCancel`](api/router/NavigationCancel)| Triggered when navigation is canceled. This can happen when a Route Guard returns false during navigation, or redirects by returning a `UrlTree`. |
173
+
|[`NavigationCancel`](api/router/NavigationCancel)| Triggered when navigation is canceled. This can happen when a Route Guard returns false during navigation, or redirects by returning a `UrlTree` or `RedirectCommand`. |
174
174
|[`NavigationError`](api/router/NavigationError)| Triggered when navigation fails due to an unexpected error. |
175
175
|[`Scroll`](api/router/Scroll)| Represents a scrolling event. |
0 commit comments