How do you read route parameters and query parameters?
Model answer
For a route like users/:id, you can read the id from ActivatedRoute (paramMap) or, with withComponentInputBinding enabled, receive it directly as a component input. Query parameters (?page=2) are read from queryParamMap in the same way.
Remember that if the user goes from users/1 to users/2, Angular reuses the component, so react to changes through the observable or input instead of reading the value only once.
Tips
- Mention the reuse trap.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.