Skip to content

Instantly share code, notes, and snippets.

@nhh
Created May 29, 2018 09:35
Show Gist options
  • Save nhh/d080cbc9f39bd8a245424d978b9e4287 to your computer and use it in GitHub Desktop.
Save nhh/d080cbc9f39bd8a245424d978b9e4287 to your computer and use it in GitHub Desktop.
Routing with secured child views
import { Routes, RouterModule } from "@angular/router";
import { NgModule } from '@angular/core';
import { DashboardComponent } from './component/dashboard/dashboard.component';
import { SettingsComponent } from './component/settings/settings.component';
import { IsAuthenticatedGuard } from '../shared/guard/is-authenticated.guard';
const routes: Routes = [
{
path: 'admin',
canActivate: [IsAuthenticatedGuard],
canActivateChild : [IsAuthenticatedGuard],
component: AdminComponent,
children: [
{
path: "dashboard",
component: DashboardComponent
},
{
path: "settings",
component: SettingsComponent
}
]
}
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class FreelancerRouting {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment