import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { UserListComponent } from './user-list/user-list.component'; import { UserDetailComponent } from './user-detail/user-detail.component'; const routes: Routes = [ { path: "", component: UserListComponent }, { path: 'list', redirectTo: "", pathMatch: "full" }, { path: "user/:id", component: UserDetailComponent } ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { }