ActivatedRoute
Provides access to route params, query params, and data for the active route.
Syntax
const route = inject(ActivatedRoute) Returns
ActivatedRoute — Observables and snapshots of route state.
Examples
import { Component, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { toSignal } from '@angular/core/rxjs-interop';
import { map } from 'rxjs';
@Component({ selector: 'app-user', standalone: true, template: `{{ id() }}` })
export class UserComponent {
private route = inject(ActivatedRoute);
id = toSignal(this.route.paramMap.pipe(map((p) => p.get('id'))));
}
Notes
Use the observable streams (paramMap, queryParamMap, data) for values that
change while the component stays mounted; use snapshot for one-time reads.
With withComponentInputBinding you can bind route params directly to signal
inputs instead.