Created
May 25, 2019 18:31
Lazy loading
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 { RouterModule, Routes } from '@angular/router'; | |
import { HomeComponent } from './home/home.component'; | |
const routes: Routes = [ | |
{ path: '', component: HomeComponent }, | |
// the special syntax points to a file and class in it that is the module to be lazy loaded | |
{ path: 'login', loadChildren: './login/login.module#LoginModule' }, | |
{ path: 'personal', loadChildren: './personal/personal.module#PersonalModule' }, | |
{ path: '**', component: HomeComponent } | |
]; | |
@NgModule({ | |
imports: [RouterModule.forRoot(routes)], | |
exports: [RouterModule] | |
}) | |
export class AppRoutingModule {} |
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 { BrowserModule } from '@angular/platform-browser'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { AppComponent } from './app.component'; | |
import { HomeModule } from './home/home.module'; | |
import { SharedModule } from './shared/shared.module'; | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule, | |
AppRoutingModule, | |
HomeModule, | |
SharedModule | |
], | |
providers: [], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment