该应用程序留在这里:https ://angular-dqpbqa.stackblitz.io 。我在做什么错?它最初也会加载英雄列表,但路径是''。
功能模块的延迟加载不起作用。我在每个功能模块中创建了单独的路由。使用 loadchildren 属性动态加载模块
const routes: Routes = [
{ path: 'dashboard',
loadChildren: () => import('./dashboard/dashboard.module').then(mod =>
mod.DashboardModule)
},
{ path: 'heroes',
loadChildren: () => import('./heroes/heroes.module').then(mod =>
mod.HeroesModule)
},
{ path: 'detail/:id',
loadChildren: () => import('./hero-detail/hero-detail.module').then(mod
=> mod.HeroDetailModule)
},
{
path: '',
redirectTo: '',
pathMatch: 'full'
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
stackblitz 可编辑:https ://stackblitz.com/edit/angular-dqpbqa