Angular 将子管线添加到子管线
angular 2路由器目前不允许多个嵌套级别 如果您有如下结构:Angular 将子管线添加到子管线,angular,Angular,angular 2路由器目前不允许多个嵌套级别 如果您有如下结构: /users/profile/detail 如何链接到/users/profile,当我点击user组件中的按钮时,它应该路由到profile组件 代码: 您需要定义详细信息到配置文件路由的子路由,以便能够导航到/users/profile/detail。只需将第二个子路由添加到profile,并在导航到/users/profile时显示一个虚拟组件 const appRoutes: Routes = [ { pa
/users/profile/detail
如何链接到/users/profile
,当我点击user
组件中的按钮时,它应该路由到profile
组件
代码:
您需要定义
详细信息
到配置文件
路由的子路由,以便能够导航到/users/profile/detail
。只需将第二个子路由添加到profile
,并在导航到/users/profile
时显示一个虚拟组件
const appRoutes: Routes = [
{
path: 'menu',
component: MenubarComponent,
children: [
{ path: 'page1', component: page1Component },
{ path: 'user', component: userComponent,
children: [
{ path: 'profile', component: profileComponent,
children: [
{ path: '', component: dummyComponent, pathMatch: 'full' },
{ path: 'detail', component: userProfileDetailComponent }
},
]
},
{ path: 'page2', component: page2Component },
{ path: 'page3', component: page3Component }
]
},
{
path: '',
redirectTo: '/login',
pathMatch: 'full'
},
{ path: 'settings', component: SettingsComponent }
];
您可以添加代码吗什么是非终点站路线?我真的不明白这个问题,你能提供一个plunkr来显示你的问题吗?你的路由器出口是否包括另一个命名的路由器出口?我假设在加载过程中,如果指定的路由器出口嵌套,这是可能的。这只是一个假设,我从未尝试过。你有没有问过维克多·萨夫金(Victor Savkin):“不工作”没有多大帮助。请发布完整准确的错误消息。Url正在进行更改,如用户/配置文件/详细信息,但未呈现详细信息组件的视图。。只有纵断面组件视图在浏览器控制台中出现任何错误?
profileComponent
的模板中是否有
?无错误。。我试图在配置文件组件中添加路由器出口,但配置文件组件的视图在配置文件组件中出现了两次。。而且在细节部分,路由2层深度没有什么特别的。我不知道会出什么问题。你能在一个扑克牌中复制吗?Plunker在“新建”按钮下提供了一个随时可用的Angular 4模板。
const appRoutes: Routes = [
{
path: 'menu',
component: MenubarComponent,
children: [
{ path: 'page1', component: page1Component },
{ path: 'user', component: userComponent,
children: [
{ path: 'profile', component: profileComponent,
children: [
{ path: '', component: dummyComponent, pathMatch: 'full' },
{ path: 'detail', component: userProfileDetailComponent }
},
]
},
{ path: 'page2', component: page2Component },
{ path: 'page3', component: page3Component }
]
},
{
path: '',
redirectTo: '/login',
pathMatch: 'full'
},
{ path: 'settings', component: SettingsComponent }
];