Last active
May 26, 2021 10:03
-
-
Save owrrpon/29222a02db4e83be168f0b626e26d562 to your computer and use it in GitHub Desktop.
angular-top-level-routing-app-router
This file contains hidden or 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
const routes: Routes = [ | |
{ | |
//Default redirection to login route. | |
path: '', | |
redirectTo: 'login', | |
pathMatch: 'full' | |
}, | |
{ | |
path: 'login', | |
component: LoginComponent | |
}, | |
//Separating the routes between login (non-secure) and secure section. | |
{ | |
path: 'secure', | |
component: SecureContainerComponent, | |
children: [ | |
{ | |
//Default redirection to dashboard route in the secure section. | |
path: '', | |
redirectTo: '/secure/dashboard', | |
pathMatch: 'full' | |
}, | |
{ | |
path: 'dashboard', | |
component: DashboardComponent | |
}, | |
//Lazy loading the feature modules. | |
{ | |
path: 'module-a', | |
loadChildren: () => import('./modules/feature-module-a/feature-module-a.module').then(m => m.FeatureModuleAModule) | |
}, | |
{ | |
path: 'module-b', | |
loadChildren: () => import('./modules/feature-module-b/feature-module-b.module').then(m => m.FeatureModuleBModule) | |
}, | |
{ | |
//For any invalid routes in secure section, redirecting to dashboard route. | |
path: '**', | |
redirectTo: '/secure/dashboard' | |
} | |
] | |
}, | |
{ | |
//For any invalid routes not in secure section, redirecting to login route. | |
path: '**', | |
redirectTo: 'login' | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment