角度2命名路由器插座不工作

时间:2017-09-12 07:33:21

标签: angular angular-ui-router angular2-routing

我使用命名的router-outlet来渲染一些组件数据。这个命名的路由器插座位于app component,带有主路由器插座。

这是我的出路:

<router-outlet name="popup"></router-outlet>

这是我的route-config:

    { path: 'contact', component: ContactComponent },
  { path: 'contact-list', component: ContactlistComponent },
  { path: 'contact-hold/:id', component: ContactOperationComponent, outlet: 'popup' },

这是我的链接:

<a [routerLink]="['\',{outlets:{popup:['hold',1]}}]">Hold</a>

route debugger image

当我更改路线配置时,它有效。但现在新问题即将来临,我无法将参数传递给我的辅助网址。

这里我试图从我的保持组件中的路由器获取参数:

this.route.queryParams.subscribe(params=> {      
      console.log(params["id"]);
    })  

1 个答案:

答案 0 :(得分:0)

这是我的相关问题的示例代码:

在打开弹出窗口之前

。网址如下图所示

enter image description here

<强> component.html

<button type="submit" [routerLink]="['/', { outlets: { popup: 'product-family/'+ productFamily.id + '/delete'} }]" replaceUrl="true" class="btn btn-danger btn-sm">
<span class="fa fa-remove"></span>
<span class="hidden-md-down">Delete</span>

<强> route.ts

export const productFamilyPopupRoute: Routes = [
    {
        path: 'product-family/:id/delete',
        component: ProductFamilyDeletePopupComponent,
        outlet: 'popup'
    }
];

点击删除按钮后,网址将更改显示在图片下方:

enter image description here

相关问题