Routing

  1. Parameters
  2. Query parameters

app.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);

Target outlets