0
0
Angularframework~5 mins

Lazy loading routes and modules in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is lazy loading in Angular routing?
Lazy loading is a technique where Angular loads feature modules only when the user navigates to their routes, instead of loading all modules at startup. This improves app startup time and performance.
Click to reveal answer
beginner
How do you define a lazy loaded route in Angular?
You use the loadChildren property in the route configuration to specify the module to load lazily. For example: <br>{ path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) }
Click to reveal answer
beginner
Why should feature modules be lazy loaded?
Lazy loading feature modules helps reduce the initial bundle size, making the app start faster. It also loads code only when needed, saving bandwidth and improving user experience.
Click to reveal answer
intermediate
What Angular CLI command helps generate a module ready for lazy loading?
Use ng generate module module-name --route route-name --module app.module.ts. This creates a module with routing configured for lazy loading.
Click to reveal answer
intermediate
What is the role of the RouterModule.forChild() method in lazy loaded modules?
In lazy loaded modules, RouterModule.forChild() defines the routes specific to that module. It is used instead of forRoot() which is only called once in the root module.
Click to reveal answer
Which property is used to lazy load a module in Angular routes?
AredirectTo
Bcomponent
CpathMatch
DloadChildren
What does lazy loading improve in an Angular app?
ACSS styling
BDatabase queries
CInitial load time and performance
DServer-side rendering
Which method is used to define routes inside a lazy loaded module?
ARouterModule.forChild()
BRouterModule.forRoot()
CNgModule.forRoot()
DNgModule.forChild()
What Angular CLI flag helps generate a lazy loaded module with routing?
A--route
B--lazy
C--module
D--routing
When is a lazy loaded module loaded in Angular?
AAfter the root module loads
BWhen the user navigates to its route
CAt app startup
DWhen the server sends a signal
Explain how lazy loading routes and modules work in Angular and why it is useful.
Think about when Angular loads the code for a feature module.
You got /4 concepts.
    Describe the steps to set up a lazy loaded feature module with routing in Angular.
    Consider CLI commands and route configuration.
    You got /4 concepts.