简体   繁体   中英

Deep routing in angular2

I am trying to create routing in angular 2 with below scenario

home.component:

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

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.

  1. Home link: <a [routerLink]="['Home']">Home</a>
  2. Route1 link: <a [routerLink]="['Route1', {id: 'id'}]">Route1</a>
  3. Route2 home link: <a [routerLink]="['Route2', {id: 'id'}]">Route2 Home</a>
  4. Route2 edit link: <a>Route2 Edit</a> How to configure routerLink for this?
  5. Route2 details link: <a>Route2 details</a> How to configure routerLink for this?

Thanks.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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