我想讓我的路由在我的Angular 2應用程序中工作。Angular 2 - 兒童路由加載父組件
這裏是我使用的app.routes.ts
文件
export const ROUTES: Routes = [
{ path: '', component: PublicComponent, data: { title: 'Heroes List' } },
{ path: 'home', component: PublicComponent },
{ path: 'admin', component: PrivateComponent, children: [
{ path: '', component: PrivateComponent },
{ path: 'account-settings', component: AccountSettingsComponent, children: [
{ path: '', component: UserInformationComponent},
{ path: 'user-information', component: UserInformationComponent},
{ path: 'companys-information', component: CompanysInformationComponent}
] },
] },
{ path: '**', component: NoContentComponent },
];
每次我嘗試瀏覽到它加載了父路由的子路由的一個代碼。
因此,可以說比如我去: -
http://localhost:4200/#/admin
它拉動正確的組件PrivateComponent。
但是,當我瀏覽到: -
http://localhost:4200/#/admin/account-settings
或帳戶設置任何兒童作爲你可以看到上面的代碼表示它加載了PrivateComponent
而不是AccountSettingsComponent
或UserInformationComponent
。
我是否在代碼中丟失了某些東西來使其工作?
該應用程序是使用Angular CLI生成的。
預先感謝您。
謝謝,我會接受一旦它讓我。 –