如何从子级导航到父级:
localhost/#/pages/config/out-devices/1000
到父级的导航为:
localhost/#/pages/config/out-devices
我尝试了以下方法:
back(){
this.router.navigate("../", {relativeTo: this.route});
}
在子组件中但被重定向到默认网站
我的routing.ts文件:
const routes: Routes = [
{ path: 'login', component: LoginComponent},
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{
path: 'pages',
canActivate: [AuthGuard],
component: PagesComponent,
children: [
{ path: '', redirectTo: 'devices'},
{ path: 'devices', component: DevicesComponent },
{ path: 'groups', component: GroupsComponent },
{
path: 'config',
component: ConfigComponent,
children: [
// general
{ path: 'out-devices', component: ConfigOutDevicesComponent },
{ path: 'out-devices/:id', component: ConfigOutDeviceDetailsComponent },
]
}
]
}
];
back()
方法? - Günter Zöchbauer