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
Copy file name to clipboardExpand all lines: adev/src/content/guide/routing/common-router-tasks.md
+30-11Lines changed: 30 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ To edit an item, users click an Edit button, which opens an `EditGroceryItem` co
11
11
You want that component to retrieve the `id` for the grocery item so it can display the right information to the user.
12
12
13
13
Use a route to pass this type of information to your application components.
14
-
To do so, you use the [withComponentInputBinding](api/router/withComponentInputBinding) feature with `provideRouter` or the `bindToComponentInputs` option of `RouterModule.forRoot`.
14
+
To do so, you use the [`withComponentInputBinding`](api/router/withComponentInputBinding) feature with `provideRouter` or the `bindToComponentInputs` option of `RouterModule.forRoot`.
15
15
16
16
To get information from a route:
17
17
@@ -29,25 +29,44 @@ providers: [
29
29
30
30
</docs-step>
31
31
32
-
<docs-steptitle="Add an `Input` to the component">
32
+
<docs-steptitle="Add an `input` to the component">
33
33
34
-
Update the component to have an `Input` matching the name of the parameter.
34
+
Update the component to have an `input` property matching the name of the parameter.
35
35
36
36
```ts
37
-
@Input()
38
-
setid(heroId: string) {
39
-
this.hero$=this.service.getHero(heroId);
40
-
}
37
+
id=input<string|undefined>();
38
+
effect(() => {
39
+
const heroId =this.id();
40
+
if(heroId) {
41
+
hero=this.service.getHero(heroId)
42
+
}
43
+
});
41
44
```
42
45
43
-
NOTE: You can bind all route data with key, value pairs to component inputs: static or resolved route data, path parameters, matrix parameters, and query parameters.
44
-
If you want to use the parent components route info you will need to set the router `paramsInheritanceStrategy` option:
NOTE: You can bind all route data with key, value pairs to component inputs: static or resolved route data, path parameters, matrix parameters, and query parameters.
67
+
If you want to use the parent components route info you will need to set the router `paramsInheritanceStrategy` option:
To display a 404 page, set up a [wildcard route](guide/routing/common-router-tasks#setting-up-wildcard-routes) with the `component` property set to the component you'd like to use for your 404 page as follows:
0 commit comments