Skip to content

Instantly share code, notes, and snippets.

@sasxa
Created October 16, 2016 13:17
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 sasxa/5b6c26499503c40cf41a7eef0db64172 to your computer and use it in GitHub Desktop.
Save sasxa/5b6c26499503c40cf41a7eef0db64172 to your computer and use it in GitHub Desktop.
Nested lazy loaded routes
export const routes: Routes = [
{
path: '',
component: AppComponent,
children: [
{ path: 'home', component: DummyComponent },
{ path: '', canLoad: [AuthGuard], loadChildren: './viewer/viewer.module#ViewerModule' },
// { path: '_', canLoad: [AuthGuard], loadChildren: './editor/editor.module#EditorModule' },
{ path: '**', redirectTo: 'home' },
]
},
];
@NgModule({
imports: [
RouterModule.forRoot(routes),
],
exports: [RouterModule],
})
export class AppRoutingModule { }
const routes: Routes = [
{
path: '',
children: [
{ path: '', component: EditorComponent },
{ path: ':model', component: EditorComponent },
],
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class EditorRoutingModule { }
@NgModule({
declarations: [
EditorComponent,
],
imports: [
ReactiveFormsModule,
SharedModule,
EditorRoutingModule,
],
providers: [
],
})
export class EditorModule { }
const routes: Routes = [
{
path: '',
canActivate: [AuthGuard],
component: ViewerComponent,
children: [
{ path: '_', loadChildren: './editor/editor.module#EditorModule' },
{ path: '', component: DummyComponent },
]
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ViewerRoutingModule { }
@NgModule({
declarations: [
ViewerComponent,
],
imports: [
ViewerRoutingModule,
ReactiveFormsModule,
SharedModule,
],
providers: [ ],
})
export class ViewerModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment