WARNING: The code below only works on Angular2 beta
You can implement helper routing. The file structure should be the same.
app.ts
@RouteConfig([ ... { path: '/product/...', component: Product, name: 'Product'} { path: '/home', component: Home, name: 'Home'} ... ]) export class App { }
product.ts
@Component({ selector: 'product', templateUrl: 'app/components/product/product.html', directives: [ROUTER_DIRECTIVES] }) @RouteConfig([ ... { path: 'product-one', component: ProductOne, name: 'Product-one' }, { path: 'product-two', component: ProductTwo, name: 'Product-two', useAsDefault: true }, ... ]) export class Product { constructor(location: Location, public router: Router) {} goToProductOne() { this.router.navigate(['Product','Product-one']) } }
product.html
... <a [routerLink]="['./Product-one']"> Product One </a> <a [routerLink]="['/Home']"> Home </a> ...
Where ['./Product-one'] is the subroutine, and ['/ Home'] is the parent route
source share