Created
March 20, 2018 06:21
-
-
Save alexzuza/772d820ea0efaacfb2842f5e88db39fe to your computer and use it in GitHub Desktop.
DI simple application with lazy loading
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
@Component({ | |
selector: 'child', | |
template: ` | |
Child | |
<router-outlet></router-outlet> | |
` | |
}) | |
export class ChildComponent {} | |
... | |
@NgModule({ | |
imports: [ | |
BrowserModule, | |
RouterModule.forRoot([ | |
{ | |
path: 'child', component: ChildComponent, | |
children: [ | |
{ | |
path: 'grand-child', | |
loadChildren: './grand-child/grand-child.module#GrandChildModule'} | |
] | |
}, | |
{ path: '', redirectTo: '/child', pathMatch: 'full' } | |
]) | |
], | |
declarations: [ | |
AppComponent, | |
ChildComponent | |
], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment