Please enable JavaScript.
Coggle requires JavaScript to display documents.
Angular Router - Coggle Diagram
Angular Router
Navigation Guard
-
Add to Routes
{ path: '...', canActivate: [AuthGuard], component: ...}
-
{ path: '...', canActivateChild: [AuthGuard], component: ...}
-
-
-
-
Nested Routes
{ path: '/users', component: UsersComponent, children: [{ path: ':id', component: UserComponent }, ...]}
-
Preserve Query Params
this.router.navigate(['edit'], { relativeTo: this.route, queryParamsHandling: 'preserve' })
Use queryParamsHandling property ('merge', 'preserve' and so on)
Wildcard Routes
Not Found
{ path: 'not-found', component: NotFoundComponent}
Wildcard
{ path: '**', redirectTo: '/not-found'}
-
/
{ path: '', redirectTo: '/login', pathMatch: 'full'}
if this route is placed at the top and without 'pathMatch' set to 'full', then infinite loop will occur.
-
Passing Parameters
[{ path: 'users/:id', component: UserComponent }]
-
-
-
Hash Mode
RouterModule.forRoot(appRoutes, { useHash: true });
Server can understand and ignored the path after /#/, so our spa will not break