Complete the code to lazy load the AdminModule in Angular routing.
const routes: Routes = [
{ path: 'admin', loadChildren: () => import('./admin/admin.module').[1] }
];catch or finally instead of then.load which is not a function.Lazy loading uses import() with then to load the module and return it.
Complete the code to define a lazy loaded route for the UserModule.
const routes: Routes = [
{ path: 'user', [1]: () => import('./user/user.module').then(m => m.UserModule) }
];component instead of loadChildren.children without lazy loading.The property loadChildren is used to lazy load a module in Angular routes.
Fix the error in the lazy loading syntax for the DashboardModule.
const routes: Routes = [
{ path: 'dashboard', loadChildren: () => import('./dashboard/dashboard.module').[1] }
];dashboardModule or Dashboardmodule.then.The correct syntax uses then(m => m.DashboardModule) with exact casing.
Fill both blanks to create a lazy loaded route with a preloading strategy.
import { RouterModule, Routes, [1] } from '@angular/router'; const routes: Routes = [ { path: 'settings', loadChildren: () => import('./settings/settings.module').[2] } ];
then.Use PreloadAllModules to preload lazy modules and then(m => m.SettingsModule) to load the module.
Fill all three blanks to configure lazy loading with a preloading strategy and a route guard.
import { RouterModule, Routes, [1] } from '@angular/router'; import { AuthGuard } from './guards/auth.guard'; const routes: Routes = [ { path: 'profile', loadChildren: () => import('./profile/profile.module').[2], canLoad: [[3]] } ];
canLoad.Import PreloadAllModules for preloading, use then(m => m.ProfileModule) to lazy load, and protect route with AuthGuard.