Skip to content

Commit 635e41e

Browse files
committed
docs: show a redirect function in the route metadata guide
The redirect routes section only showed string targets.
1 parent a4ebd6f commit 635e41e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • apps/docs-analog/src/content/features/routing

‎apps/docs-analog/src/content/features/routing/metadata.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ export const routeMeta: RouteMeta = {
6868

6969
Navigating to `/cities` redirects to `/cities/new-york`.
7070

71+
Dynamic redirects are also supported. `redirectTo` accepts Angular's `RedirectFunction`, which provides the matched route's params, query params and data, can use `inject()`, and returns the target path or a `UrlTree`:
72+
73+
```ts
74+
export const routeMeta: RouteMeta = {
75+
redirectTo: ({ params }) => `/cities/${params['cityId']}`,
76+
pathMatch: 'full',
77+
};
78+
```
79+
7180
:::note
7281

7382
Nested redirects always require an absolute path.

0 commit comments

Comments
 (0)