Created
February 13, 2022 10:55
-
-
Save Alvaro237/f96e89e9ca0bdad7a11f6fed7873e188 to your computer and use it in GitHub Desktop.
Angular #LazyLoading
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
| Split app modules in features modules and core module, don't import in app.module.ts feature modules, they have to be imported dynamiclly |
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
| import { NgModule } from '@angular/core'; | |
| import { Routes, RouterModule } from '@angular/router'; | |
| const appRoutes: Routes = [ | |
| { path: '', redirectTo: '/recipes', pathMatch: 'full' }, | |
| { | |
| path: 'recipes', | |
| loadChildren: () => | |
| import('./recipes/recipes.module').then(m => m.RecipesModule) | |
| }, | |
| { | |
| path: 'shopping-list', | |
| loadChildren: () => | |
| import('./shopping-list/shopping-list.module').then( | |
| m => m.ShoppingListModule | |
| ) | |
| }, | |
| { | |
| path: 'auth', | |
| loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule) | |
| } | |
| ]; | |
| @NgModule({ | |
| imports: [RouterModule.forRoot(appRoutes)], | |
| exports: [RouterModule] | |
| }) | |
| export class AppRoutingModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment