简体   繁体   English

angular2中的深度路由

[英]Deep routing in angular2

I am trying to create routing in angular 2 with below scenario 我正在尝试在以下情况下在角度2中创建路由

home.component: home.component:

    @RouteConfig([
        {
            path: '/',
            name: 'Home',
            component: HomeComponent
        },
        {
            path: '/route1/:id',
            name: 'Route1',
            component: Route1Component
        },
        {
            path: '/route2/:id/...',
            name: 'Route2',
            component: Route2Component
        }
    }]

Route2.Component: Route2.Component:

    @RouteConfig([
        {
            path: '/',
            name: 'Route2Home',
            component: Route2HomeComponent
        },
        {
            path: '/edit',
            name: 'Route2Edit',
            component: Route2EditComponent
        },
        {
            path: '/details/:otherId',
            name: 'Route2Details',
            component: Route2DetailsComponent
        }
    }] 

home.html is having few links with router Links. home.html与路由器链接的链接很少。

  1. Home link: <a [routerLink]="['Home']">Home</a> 主页链接: <a [routerLink]="['Home']">Home</a>
  2. Route1 link: <a [routerLink]="['Route1', {id: 'id'}]">Route1</a> Route1链接: <a [routerLink]="['Route1', {id: 'id'}]">Route1</a>
  3. Route2 home link: <a [routerLink]="['Route2', {id: 'id'}]">Route2 Home</a> Route2主目录链接: <a [routerLink]="['Route2', {id: 'id'}]">Route2 Home</a>
  4. Route2 edit link: <a>Route2 Edit</a> How to configure routerLink for this? Route2编辑链接: <a>Route2 Edit</a>如何为此配置routerLink?
  5. Route2 details link: <a>Route2 details</a> How to configure routerLink for this? Route2详细信息链接: <a>Route2 details</a>如何为此配置routerLink?

Thanks. 谢谢。

<a [routerLink]="['/Route2', 'Route2Edit', {id: 'someValue'}]"]>Route 2 Edit</a>
<a [routerLink]="['/Route2', 'Route2Details', {id: 'someValue'}]"]>Route 2 Details</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM