Skip to content

Instantly share code, notes, and snippets.

@FSou1
Created February 25, 2020 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FSou1/8165c8161e1e367991333f2dc40a088c to your computer and use it in GitHub Desktop.
Save FSou1/8165c8161e1e367991333f2dc40a088c to your computer and use it in GitHub Desktop.
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { ProfileComponent } from './profile/profile.component';
import { NotFoundComponent } from './error/not-found/not-found.component';
import { AuthGuard } from './app-routing.guard';
import { AuthService } from './services/auth.service';
import { LoginComponent } from './login/login.component';
import { Role } from './models/role';
const routes: Routes = [
{
path: '',
children: [
{
path: '',
component: HomeComponent
},
{
path: 'profile',
canActivate: [AuthGuard],
component: ProfileComponent
},
{
path: 'login',
component: LoginComponent
}
]
},
{
path: 'admin',
canLoad: [AuthGuard],
canActivate: [AuthGuard],
data: {
roles: [
Role.Admin,
]
},
loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule)
},
{
path: '**',
component: NotFoundComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: [
AuthGuard,
AuthService
]
})
export class AppRoutingModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment