Created
February 25, 2020 03:20
-
-
Save FSou1/8165c8161e1e367991333f2dc40a088c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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