我有一个问题,其中子路径在应用程序根级别呈现。从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 },
];
是否有人对为什么这些实践提供缺省路由在根应用呈现的想法零件?