我的顶部菜单模块对路由和模块一无所知,它们将在从 api 加载之前用于菜单项。
var routeConfig = [
{loadChildren: "./widget1.ts#Widget1Module", path: "widget1.ts"},
{loadChildren: "./widget2.ts#Widget2Module", path: "widget2.ts"},
{loadChildren: "./widget3.ts#Widget3Module", path: "widget3.ts"}
]; // this must be loaded before AppRoutingModule inject
@NgModule({
imports: [
RouterModule.forRoot(
routeConfig
)
],
exports: [ RouterModule ]
})
export class AppRoutingModule {
};
现在我只是使用 routeConfig 作为全局变量,并在角度导入模块之前从纯 javascript 发出请求。如何正确执行?