【发布时间】:2017-12-26 09:21:27
【问题描述】:
我目前正在使用 Angular 5。我在路由器配置及其组件内容的呈现方面遇到了问题。如下是我的路由器配置。
const appRoutes: Routes = [
{ path: "", pathMatch: "full", redirectTo: "home" },
{
path: "home", component: HomeComponent
},
{
path: "applications", component: ApplicationsComponent,
children: [{
path: ":applicationId/privacysettingsforapplications", component: PrivacysettingsforapplicationsComponent,
children: [
{ path: "", pathMatch: "full", redirectTo: "services" },
{
path: "services", component: PrivacysettingsforapplicationservicesComponent
},
{
path: "data", component: PrivacysettingsforapplicationdataComponent
}]
}]
},
{
path: "devices", component: DevicesComponent,
},
];
我们有一个主要的<router-outlet></router-outlet>,其中 angular 加载其父组件的所有内容。这里ApplicationsComponent 有一个孩子PrivacysettingsforapplicationsComponent 又有两个孩子(PrivacysettingsforapplicationservicesComponent and PrivacysettingsforapplicationdataComponent 即:服务和数据)。
我想检查是否有任何方法可以在主 <router-outlet> 而不是其直接父 <router-outlet> 上加载(PrivacysettingsforapplicationsComponent)子级,即。 ApplicationComponent 的。我检查过的一种方法是将子组件作为父组件的对等,但是我的面包屑模块无法识别谁是该组件的真正父组件PrivacysettingsforapplicationsComponent。
【问题讨论】:
标签: javascript angular angular2-routing angular4-router