我有一个Angular 5应用程序,可以动态加载功能模块并在主路由器插座中显示其内容。下面的代码显示了我的基本配置:
来自根模块(主路由器出口)的应用程序组件:
<router-outlet></router-outlet>
路由root配置(从传递的URL动态加载模块):
const routes: Routes = [
{ path: 'module1', loadChildren: ...},
{ path: 'module2', loadChildren: ...}
];
export const AppRoutes = RouterModule.forRoot(routes);
功能模块之一的示例路由:
const routes: Routes = [
{ path: 'report/:reportId', component: ReportComponent}
];
export const AppRoutes = RouterModule.forChild(routes);
及其包含另一个路由器出口的app.component:
<router-outlet></router-outlet>
这样的配置可以正常工作-如果我转到mysite.com/module1,则加载了module1,angular将控制权交给了功能模块路由器,因此访问mysite.com/module1/report/2会在功能模块的路由器出口内显示ReportComponent。 。
我现在要做的是将TabsComponent添加到我的主模块中,以便能够从多个选项卡组成页面,其中每个选项卡将包含一个特定的模块。我想以某种方式将已指定的路由用于root用户,而不用手动将其作为TabsComponent的子代重复,并将功能模块加载到TabsComponent的路由器出口中。
tabs.component:
<tabs-navigation></tabs-navigation>
<router-outlet></router-outlet>
tabs.configuration(通过http在运行时动态加载):
{
pageId: "page1",
tabs: [{
tabId: "tab1",
module: "module1",
params: "report/2"
}, {
tabId: "tab2",
module: "module2"
}]
}
以及我的路由配置中用于root的其他行:
{ path: 'tabs/:pageId', component: TabsComponent}
从现在开始,当我访问mysite.com/tabs/page1时:
我的两个问题是:
我有一个Angular 5应用程序,可以动态加载功能模块并在主路由器插座中显示其内容。下面的代码显示了我的基本配置:来自root的app.component ...
@ syntax_error,这就是我的做法。我对Angular也有类似的要求。我的应用程序有一个页面,显示多个用户,每个用户都有一个对应的详细视图/路线。例如