Repository navigation
docs: fix the routing guide examples - #71412
Open
erkamyaman wants to merge 1 commit into
Open
erkamyaman wants to merge 1 commit into
erkamyaman wants to merge 1 commit into
Conversation
Several examples and statements in the routing guides do not match the router. The redirect function example in the redirecting routes guide has no `pathMatch`. With the default `prefix`, `restaurant/:location/menu` also matches the destination URLs the page defines, such as `restaurant/downtown/menu/lunch`, and the leftover segment is appended to the redirect result. Add `pathMatch: 'full'`. The `CustomRouteReuseStrategy` example passes `handle: DetachedRouteHandle | null` into a `Map<Route, DetachedRouteHandle>`, which does not compile under strict mode. Guard the `set` call with `if (handle)`. The resolver guide says the data comes from the snapshot using `signal`, but the example uses `toSignal` on the `data` observable. Three snippets in the read route state and outlet guides use `inject` or `Signal` without importing them, and `userId` is `string | null` because `paramMap.get()` returns `null`. The URL matcher guide says the page shows `Hello, Angular!`, but the example template renders `Hello Angular!`. The `canActivateChild` guard runs once for each child route being activated, so "once for each of them" replaces "once for both components".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
redirectTowith nopathMatch. With the defaultprefix, the route also matches the page's own destination URLs like/restaurant/downtown/menu/lunch, so those URLs break. I addedpathMatch: 'full'.CustomRouteReuseStrategyexample doesn't compile under strict mode, becausehandlecan benull. I guarded it withif (handle).inject,SignalortoSignalwrongly or without importing them, anduserIdneeds to bestring | null.Hello, Angular!, but it rendersHello Angular!.canActivateChildruns once for each child route being activated, not once for both.