【发布时间】:2023-03-30 14:55:01
【问题描述】:
我刚刚超过了 2MB 标记,所以我决定实施延迟加载来处理我的大量批次。因此,我对导入、entryComponents 和提供程序有疑问。将它们全部归结为一个问题:
我将什么导入 app-routing.module.ts 以及将什么导入 login-routing.module.ts
自从我使用:
- 角度模块
- 角材料模块(垫对话框,因此是入口组件)
- 服务众多(所有组件中仅调用部分服务)
- 其他 npms
这是我的 app-routing.module.ts:
const routes: Routes = [
{
path: '',
component: AppComponent,
children: [
{
path: '',
pathMatch: 'full',
redirectTo: '/login'
},
{
path: '**',
component: LoginComponent
},
{
path: 'login',
loadChildren: () => import('./account/login/login.module').then(m => m.LoginModule)
}
]
}
@NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true})],
exports: [RouterModule]
})
export class AppRoutingModule { }
这是我的 login-routing.module.ts:
const routes: Routes = [
{
path: '',
component: LoginComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class LoginRoutingModule { }
【问题讨论】:
标签: angular lazy-loading angular8 angular2-providers