Skip to content

Instantly share code, notes, and snippets.

@Alvaro237
Created February 13, 2022 10:55
Show Gist options
  • Select an option

  • Save Alvaro237/f96e89e9ca0bdad7a11f6fed7873e188 to your computer and use it in GitHub Desktop.

Select an option

Save Alvaro237/f96e89e9ca0bdad7a11f6fed7873e188 to your computer and use it in GitHub Desktop.
Angular #LazyLoading
Split app modules in features modules and core module, don't import in app.module.ts feature modules, they have to be imported dynamiclly
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