2017-09-29 9 views
2

があれば、私は現在、このsiteを使用しているいるexperiments/1(browsePanel:overview):私のアプリで

からexperiments/1ルータだろうルートを与えられたことを、私の子ルートへのデフォルトルートを持つようにしたいルート子どもたちと補助ルートへのルーティング私の参照が、それは私が達成したいものとほぼ同じ例があり、ここではそのコードです:

{ 
    path: 'team/:id', 
    children: [ 
     { path: '', pathMatch: 'full', redirectTo: 'list' }, 
     { path: 'list', component: TeamListComponent, 
     children: [ 
     { path: '', pathMatch: 'full', redirectTo: 'default' }, 
     { path: 'default', component: DefaultComponent } 
     ] 
     }, 
     { path: '', pathMatch: 'full', redirectTo: 'details' outlet: 'aux' } 
    ] 
    } 

彼らのコードは、私がやろうとしています何よりも複雑ですが、いくつかの理由のために私はこのエラーを取得します: "Invalid configuration of route 'experiments/:id/': a componentless route cannot have a named outlet set"

ここ

は私のコードです:自分のコードを仮定

{ path: "experiments/:id", component: BrowseExperimentsComponent , children:[ 
     {path: '', redirectTo: 'overview', pathMatch: 'full', outlet:'browsePanel'}, 
     {path:'overview',component: BrowseOverviewComponent, outlet: 'browsePanel', resolve:{project:ProjectResolverService}}, 
     {path:':id', component: ExperimentDetail, outlet: 'browsePanel',resolve: {experiment: ExperimentResolverService}}] 
}, 

は、機能と私はcomponentlessルートに出口を有するため、このエラーが出る理由を私は理解していない良い方法です。私は "outlet: 'browsePanel'を削除してエラーを消しましたが、" experimental/1 "を提供するときに子にルーティングしません。

私のリダイレクトパスにコンセントを置くことができない、私はどのように補助ルートにルーティングするのですか?ありがとう

+0

ビット遅すぎるのですが、私は同じ問題を抱えており、解決策を見つけることができませんでした。方法を見つけましたか? –

+0

悲しいことに、まだコンセントにリダイレクトする方法は不明です。 –

+0

私は多くの問題を発見しましたが、解決策のどれも私にとってはうまくいかず、最新の角度バージョンを使用しています。現在、Guardを使用して、アクティブなルートにある最初の子ルートに手動でリダイレクトしようとしています。 –

答えて

2

私は同じ問題がありました。私はそれがこの(角5.2.5)のように、子ルートの絶対パスにredirectToプロパティを変更することにより、作業ました:私はこのことができます願ってい

{ 
    path: "experiments/:id", 
    component: BrowseExperimentsComponent, 
    children: [ 
     {path: '', pathMatch: 'full', redirectTo: '/experiments/:id/(browsePanel:overview)'}, 
     {path: 'overview', component: BrowseOverviewComponent, outlet: 'browsePanel', resolve:{project:ProjectResolverService}}, 
     {path:':id', component: ExperimentDetail, outlet: 'browsePanel', resolve: {experiment: ExperimentResolverService}} 
    ] 
}, 

ます:)