Set up route:
- const routes: Routes = [
- {path: ”, component: HomeComponent}, //localhost:4200/
- {path: ‘aaa’, component: AaaComponent, //localhost:4200/aaa
- children: [
- {path: ‘:id’, component: AaaSubComponent} //localhost:4200/aaa/abc(id is value)
- ]} ,
- children: [
- {path: ‘**’, redirectTo: ‘/’}
- ]
import: RouterModule to app.module.ts file’s @NgModule({imports: [RouterModule.forRoot(routes)]})
You also can set up routing.module.ts file and then import to app.module.ts file