Bird
0
0

In Angular, which technique allows you to delay the loading of a feature module until after a user successfully authenticates?

hard📝 Application Q8 of 15
Angular - Performance Optimization
In Angular, which technique allows you to delay the loading of a feature module until after a user successfully authenticates?
AUse a route guard with <code>canLoad</code> to prevent module loading before authentication
BEagerly load the module and hide its components until login
CUse <code>preloadAllModules</code> strategy to load after login
DManually import the module in <code>app.module.ts</code> after login
Step-by-Step Solution
Solution:
  1. Step 1: Understand lazy loading with authentication

    Angular provides route guards like canLoad to control if a lazy loaded module should be loaded.
  2. Step 2: Identify correct approach

    Using canLoad prevents the module from loading until the guard allows it, typically after authentication.
  3. Step 3: Eliminate incorrect options

    Eagerly load the module and hide its components until login loads eagerly which defeats lazy loading, C preloads modules regardless of login, and D is manual and not dynamic.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Use canLoad guard to delay module loading [OK]
Quick Trick: Use canLoad guard to delay lazy loading until login [OK]
Common Mistakes:
  • Eagerly loading modules instead of lazy loading
  • Using preload strategies that ignore authentication
  • Manually importing modules instead of lazy loading

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes