const routeConfig: Routes = [
{ path: 'pizze', component: PizzeComponent },
{ path: 'order/:id', component: OrderComponent },
{ path: '', redirectTo: 'pizze',
pathMatch: 'full'},
{ path: '**', component: NotFoundComponent }
];
@NgModule({
imports: [
RouterModule.forRoot(routeConfig)
]
})
export class AppModule { }
<nav>
<ul>
<li><a routerLink="/pizze">Pizze</a></li>
<li><a routerLink="/order">Orders</a></li>
</ul>
</nav>
<h1>Welcome</h1>
<navigation-bar></navigation-bar>
<router-outlet></router-outlet>
routerLink -> updates URL -> router sees changes -> sequentially check routerConfig -> selects the first match path -> load component defined for that path -> find <router-outlet></router-outlet> directive -> display component
this.route.navigate(['employee',id])
this.route.navigate(['employee',{name:'ab'}]));
this.route.navigate(['employee'],{queryParams:{name:'a'}})