<base href="/">
in htmlapp.module.ts
@NgModule({
imports: [
routing // from "app.routes.ts" below
],
// ...
app.routes.ts
const routes: Routes = [
// redirection
{path: '', redirectTo: 'view/posts', pathMatch: 'full'},
// standalone page
{path: 'profile', component: ProfilePageComponent},
// child view (the sidebar with the widgets is shared)
{
path: 'view',
component: ViewComponent,
children: [
{path: 'posts', component: PostsPageComponent},
{path: 'post/:id', component: PostPageComponent}
]
},
// fallback
{path: '**', component: PageNotFoundComponent}
];
export const routing = RouterModule.forRoot(routes);
<router-outlet></router-outlet>
in the html template.<router-outlet name="sidebar"></router-outlet>