When will Angular routes use loadChildren?

excuse me, when can I use loadChildren to route? On the Internet, it is said that the loading sub-module, in the project, what is the sub-module ah. How is this "sub-module" design specification defined?
do you have any examples for reference.?


when you want to delay loading a set of routes, consider using loadChildren. In fact, the main purpose of
is to lighten the load and improve the performance of angular.

for example, you define two routes

{ path: 'login', component: LoginPage },
{ path: 'user', loadChildren: './modules/user.module-sharpUserModule'},

one is the-sharplogin, static route, which loads the loginPage together when the route is initialized.
one is-sharpuser, dynamic routing, which uses loadChildren, to delay loading UserModule
for example, in your application, you never need to jump to-sharpuser, and the content under the UserModule does not need to be loaded at all.
especially if you have a lot of pages below your UserModule, the performance improvement will be significant.

and this UserModule is actually a module, of angular
you can put User-related components, services, and even the secondary routing configuration under the user into this UserModule.

as for the definition specification, it is to define an angular module. Just put the code you need into the corresponding data set.

@NgModule({
    declarations: [...],
    providers: [...],
    imports: [...]
    .....
});
Menu