Skip to content

docs: fix the routing guide examples - #71412

Open
erkamyaman wants to merge 1 commit into
angular:mainfrom
erkamyaman:docs-routing-guide-fix-examples
Open

erkamyaman wants to merge 1 commit into
angular:mainfrom
erkamyaman:docs-routing-guide-fix-examples

Conversation

@erkamyaman

Copy link
Copy Markdown
Contributor
  • The redirect example uses a function redirectTo with no pathMatch. With the default prefix, the route also matches the page's own destination URLs like /restaurant/downtown/menu/lunch, so those URLs break. I added pathMatch: 'full'.
  • The CustomRouteReuseStrategy example doesn't compile under strict mode, because handle can be null. I guarded it with if (handle).
  • Snippets in the resolver, route state and outlet guides use inject, Signal or toSignal wrongly or without importing them, and userId needs to be string | null.
  • The URL matcher guide says the page shows Hello, Angular!, but it renders Hello Angular!.
  • canActivateChild runs once for each child route being activated, not once for both.

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".
@pullapprove
pullapprove Bot requested a review from MarkTechson October 17, 2026 16:38
@angular-robot angular-robot Bot added the area: docs Related to the documentation label Oct 17, 2026
@ngbot ngbot Bot added this to the Backlog milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant