Bird
0
0

Given this routing config with PreloadAllModules, what happens after app startup?

medium📝 Predict Output Q4 of 15
Angular - Performance Optimization
Given this routing config with PreloadAllModules, what happens after app startup?
const routes = [
  { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) },
  { path: 'user', loadChildren: () => import('./user/user.module').then(m => m.UserModule) }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })],
  exports: [RouterModule]
})
export class AppRoutingModule {}
ABoth admin and user modules preload in background after startup.
BOnly admin module preloads; user module loads on demand.
CNo modules preload; all load on demand.
DModules preload only when user navigates to their routes.
Step-by-Step Solution
Solution:
  1. Step 1: Understand PreloadAllModules effect

    This strategy preloads all lazy modules after app startup in the background.
  2. Step 2: Apply to given routes

    Both admin and user modules are lazy-loaded and will preload automatically after startup.
  3. Final Answer:

    Both admin and user modules preload in background after startup. -> Option A
  4. Quick Check:

    PreloadAllModules preloads all lazy modules [OK]
Quick Trick: PreloadAllModules preloads all lazy modules after startup [OK]
Common Mistakes:
  • Thinking only first module preloads
  • Assuming modules load only on navigation
  • Confusing preload with eager loading

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes