2017-02-01 7 views
0

私は角度2の初心者です。私はいくつかのルーティングの練習をしようとしています。 productDetailComponentにボタンがあります。ボタンをクリックすると、ページがmoreDetailComponentにルーティングされます。角2 - ネストされたルーティング

export const TutorialRoutes: Routes =[ 
i w 
    { 
    path: 'Company', 

    component: CompanyComponent, 
    children: [ 
     {path: '', redirectTo: 'people'}, 
     {path: 'price', component: PriceComponent}, 

     {path: 'products', component: ProductComponent, 

     children:[ 

      {path: '', redirectTo:'product-details'}, 
      {path:'product-details', component:ProductDetailsComponent}, 
      {path:'more',component: MoreDetailsComponent} 

     ] 

     }, 


    ] 

    } 
]; 

//ボタンのページに移動する(moreDetailsComponent)

<button routerLink="more">Add</button> 

答えて

1

推測/からの

<button routerLink="../more">Add</button> 
+0

URLの変更(質問は私には非常に明確ではないため)詳細は/以上、ページは変更されませんでした。 –

+0

ルートが 'Company/products/product-details'で、ボタンが' ProductDetailsComponent'にある場合は 'Company/products/more'に変更してください。ボタンが他の場所にある場合、そのボタンは機能しません。 –

+0

ええ、ボタンがProductDetailsComponentにあります。ボタンをクリックすると、URLは変更されますが、ページは残りのmoreDetailsComponentに移動しません。 –

関連する問題