Angular2でルーティングの問題が発生しました。Angular2複数の名前付きアウトレットを持つ遅延ロードモジュールのルーティング
- 私のモジュールは、レイジーロードされている(これまでのところ、基本的な「loadChildren」アプローチには問題ありません)モジュール自体がロードされている
- が
問題:
以下のルーティングコードを参照してください。最初のバージョンが正しく動作しています。ルータリンクを作成すると、ルートが見つかり、エラーはスローされません。
しかし、なぜ私の最初の抜粋の仕事は、2番目のですか?私は疑似パス "テスト"を作成するだけで、この作業をする必要はありません。 2番目の例では、このエラーメッセージが表示されます。
[...]どのルートにも一致しません。 URLセグメント: 'mypathで' [...]
ワーキングルーティング:
children: export const routes: Routes = [
{
path: '',
component: ParentSplitViewComponent,
children: [
{
path: '',
redirectTo: 'test'
},
{
path: 'test',
component: SplitViewComponent,
children: [
{
path: '',
redirectTo: 'list'
},
{
path: 'list',
component: MyListComponent,
outlet: 'left'
},
{
path: ':id',
component: MyDetailComponent,
outlet: 'right'
}
]
}
]
}
];
を働いていないルーティング:
children: export const routes: Routes = [
{
path: '',
component: ParentSplitViewComponent,
children: [
{
path: '',
component: SplitViewComponent,
children: [
{
path: '',
redirectTo: 'list'
},
{
path: 'list',
component: MyListComponent,
outlet: 'left'
},
{
path: ':id',
component: MyDetailComponent,
outlet: 'right'
}
]
}
]
}
];
の命名に依存しているドントしてくださいファイルなど私はパスなどの名前を変更する必要がありました - すべてがこの観点からうまく動作します。それはちょうどルーティングについてです。
App.routing.ts構造を理解するためにレイジーロードされたモジュールの
{
path: 'mypath',
loadChildren: 'app/modules/myModule/my.module#MyModule'
},
大きな抜粋:
import [...]
@Component({
selector: 'parent-split-view-layout-container',
template: `
<h1>Parent</h1>
<router-outlet></router-outlet>
`
});
export class ParentSplitViewComponent {}
@Component({
selector: 'split-view-layout-container',
template: `
<h1>Vertical Split View</h1>
<div id="left">
<router-outlet name="left"></router-outlet>
</div>
<div id="right">
<router-outlet name="right"></router-outlet>
</div>
`
});
export class SplitViewComponent {}
/* Routing Definition */
export const routes: Routes = [
{
path: '',
component: ParentSplitViewComponent,
children: [
{
path: '',
redirectTo: 'test'
},
{
path: 'test',
component: SplitViewComponent,
children: [
{
path: '',
redirectTo: 'list'
},
{
path: 'list',
component: MyListComponent,
outlet: 'left'
},
{
path: ':id',
component: MyDetailComponent,
outlet: 'right'
}
]
}
]
}
];
export const MyRouting: ModuleWithProviders = RouterModule.forChild(routes);
Angular2バージョン:
"@angular/common": "~2.4.5",
"@angular/compiler": "~2.4.5",
"@angular/core": "~2.4.5",
"@angular/forms": "~2.4.5",
"@angular/http": "~2.4.5",
"@angular/material": "^2.0.0-beta.1",
"@angular/platform-browser": "~2.4.5",
"@angular/platform-browser-dynamic": "~2.4.5",
"@angular/router": "~3.4.5",
に
を変更してみてくださいあなたは今までこの問題を解決しましたか?まだ何か働いていないのであれば、私は答えとして投稿してくれる何かを持っています。 –