[ad_1]
I’m learning Angular (version 12), I understand the benefits of using lazy load by implementing loadChildren in nested paths. According angular doc. the way to implement loadChildren is by importing a module:
const routes: Routes = [
{
path: 'customers',
loadChildren: () => import('./customers/customers.module').then(m => m.CustomersModule)
},
{
path: 'orders',
loadChildren: () => import('./orders/orders.module').then(m => m.OrdersModule)
}
];
It says as an example: “This creates a customers folder having the new lazy-loadable feature module CustomersModule defined in the customers.module.ts file”
In some other places like here, they import a Routing Module directly in the loadChildren declaration:
It says: “You must specify a routing module for loadChildren. This module must define the routes and should import all relevant ng modules”.
A Module is for importing components, pipes, provide services, etc. A Routing Module is focused for setting routes.
Besides of the sintax difference, when is better to use on over another?
[ad_2]