Avatar ·

How to pass data to an Angular component during routing?

Hi everyone! I recently started learning Angular and encountered a problem with passing data between components when navigating between routes. I have an application with a user list and a detail page for each user. I'm using Angular Router for navigation, but I can't figure out how to properly pass the user ID or other data to the component that is displayed after navigation. Here is my TypeScript code: ```typescript // app-routing.module.ts const routes: Routes = [ { path: 'users', component: UserListComponent }, { path: 'users/:id', component: UserDetailComponent } ]; // user-list.component.ts @Component({...}) export class UserListComponent { users = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]; goToUser(userId: number) { // How to pass