Angular implements lazy loading of custom module routing; configures custom module routing and sub-routing

Green in the picture indicates newly created files; yellow indicates changed files;

1. Create a new project

ng new angularlazyload

2. Create a user module and configure routing

ng g module module/user --routing

As shown in the picture:
Insert image description here

3. Create user component under module/module

ng g component module/user

As shown in the picture:

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-c5Qbqdl2-1687604549321)(./images/image-20230624132630899.png)]

4. Implement lazy loading of routes

Modify the following files in order:

Insert image description here

#1 user-routing.module.ts

Guess you like

Origin blog.csdn.net/qq_39962271/article/details/131365225