Q1. How do you define route parameters?
Route parameters are defined with a colon in the path. Example:
{ path: ''users/:id'', component: UserDetailComponent }
The :id is a placeholder for the actual value. Multiple parameters are possible: ''users/:id/posts/:postId''.Q2. How do you access route parameters in a component?
Inject ActivatedRoute and subscribe to params or paramMap. Example:
constructor(private route: ActivatedRoute) {}
ngOnInit() { this.route.params.subscribe(params => { this.id = params[''id'']; }); }
paramMap provides a more robust API with get method.Q3. What is the difference between snapshot and subscription for params?
snapshot gives the initial parameter value once. Use it if the component is destroyed and recreated on param change (default for same route). Subscription is needed if the component might be reused (same component for different params) and you need to react to changes.
Q4. How do you access query parameters?
Similarly, use ActivatedRoute.queryParams or queryParamMap. Example:
this.route.queryParams.subscribe(params => { this.page = params[''page'']; });
queryParamMap provides a snapshot with get method.Q5. What is the ActivatedRoute interface?
ActivatedRoute contains information about the current route, including URL, parameters, query parameters, data, and child routes. It''s injected into components that need route info. It provides both snapshot (static) and observable (reactive) access.
