外部Angular应用程序/模块:
@NgModule({
declarations: [
HelloComponent
],
imports: [
CommonModule,
UpgradeRoutingModule
],
exports: [],
providers: [],
bootstrap: []
})
export class UpgradeModule { }
UpgradeRoutingModule:
const upgradeRoutes: Routes = [
{
path: '',
component: HelloComponent
}
];
@NgModule({
imports: [ RouterModule.forChild(upgradeRoutes)],
exports: [RouterModule]
})
export class UpgradeRoutingModule { }
主应用中的路由:
export const ROUTES = [
{
path: '',
component: HomePageComponent,
data: {
breadcrumbs: [],
sortProductsBy: CONFIG.urlParams.sortProductsBy.alphabetical
},
resolve: {
products: PropositionsResolver
}
},
{
path: 'childoo',
loadChildren: '../mymodule/src/app/app.module#UpgradeModule'
}
]
loadChildren路径:实际路径应该来自 node_module ,但是我正在测试该模块,试图弄清楚为什么我在得到错误的同时提供应用程序。 主应用程序在没有该子路径的情况下可以很好地工作,但是很奇怪的是,如果我仅在应用程序投放后才添加子路径(因此在应用程序运行时,显然--watch是活动的),它也可以工作