我有一個問題,其中子路徑在應用程序根級別呈現。從Angular2中的其他模塊中加載孩子
我的應用程序使用導入SecureModule和PublicModule的根應用程序模塊構建。然後SecureModule導入一個ProviderModule和PracticeModule。每個模塊使用.forChild定義它自己的路由(除定義forRoot的AppModule外)。出於某種原因,所有默認路徑(以''作爲路徑列出的路徑)位於根應用程序模塊級別的每個模塊中。
的SecureComponent是定義佈局對安全區,並具有它自己的路由器 - 出口的特徵部件(無選擇)。正如您從根樹中可以看到的那樣,Practice和Provider模塊路徑完全位於其下。但是,Practice和Provider模塊也會直接從AppComponent中取消。
我懶加載子路徑通過loadChildren和使用pathMatch完全在我的默認路徑,所以我不知道他們爲什麼附加到根組件。
我的安全模塊的路線被限定爲這樣:
export const secureRoutes = [
{
path: 'secure', component: SecureComponent, children: [
{ path: '', redirectTo: 'firstuse', pathMatch: 'full' },
{ path: 'firstuse', component: FirstUseComponent },
{ path: 'practice', loadChildren: './+practice#PracticeModule' },
{ path: 'provider', loadChildren: './+provider#ProviderModule' }
]
},
];
export const practiceModuleRoutes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: PracticeDashboardComponent },
{ path: ':id', component: PracticeViewerComponent }
];
我的應用程序的路線被定義爲:
我的實踐途徑爲被定義
export const appModuleRoutes: Routes = [
{ path: '', redirectTo: 'public', pathMatch: 'full' },
{ path: 'public', component: PublicComponent },
{ path: 'id_token', redirectTo: 'secure' },
{ path: 'logoff', component: LogoffComponent },
{ path: 'Unauthorized', component: UnauthorizedComponent },
{ path: '**', component: NoContentComponent },
];
是否有人對爲什麼這些實踐提供缺省路由在根應用呈現的想法零件?