角度-从子级到父级组件的RouterLink

时间:2020-06-11 14:56:54

标签: javascript angular routes parent routerlink

在我的路由模块上:

{
    path: 'walkthrough',
    title: 'customer_app.customer.walkthrough.pageTitle',
    loadChildren: './walkthrough/walkthrough.module#WalkthroughModule'
}

在我的 WalkthroughModule 上:

const ROUTES = [
  {
    path: 'dashboard',
    children: [
      {
        path: 'new',
        component: WalkthroughDashboardPanelPageComponent
      },
      {
        path: '',
        component: WalkthroughDashboardComponent
      }
    ]
  },
  {
    path: '',
    component: WalkthroughLayoutComponent
  }
];

,并且在 WalkthroughDashboardComponent 上,我有:

<button type="button" mat-button color="primary" [routerLink]="['..']"> Lien vers walkthrough </button>

我想要的东西:

我在 / walkthrough / dashboard 上,我想继续在 / walkthrough

我的问题:

如果我单击 WalkthroughDashboardComponent 按钮没有任何反应,则我仍在我的 WalkthroughDashboardComponent 组件

如果我将 WalkthroughModule 更改为:

const ROUTES = [
  {
    path: 'dashboard/new',
    component: WalkthroughDashboardPanelPageComponent
  },
  {
    path: 'dashboard',
    component: WalkthroughDashboardComponent
  },
  {
    path: '',
    component: WalkthroughLayoutComponent
  }
];

但是这样做不是很干净...

你能帮我吗?

0 个答案:

没有答案