我有两个父组件User Console和Shopping Cart。
他们的路线是locahost / user-console和localhost / shopping-cart。
以下是路线档案:
const UserConsoleRoutes: Routes = [
{path:'', component:UserConsoleComponent, redirectTo:'my-profile', pathMatch:'full'},
{path: 'my-messages', component: MyMessagesComponent},
{path: 'my-profile', component: MyProfileComponent },
{path: 'my-progress', component: MyProgressComponent},
{path: 'my-courses', component: MyCoursesComponent},
{path: 'my-receipts', component: MyReceiptsComponent},
{path: 'my-credentials', component: MyCredentialsComponent},
{path: 'group-membership', component: GroupMembershipComponent}
];
export const UserConsoleRouting: ModuleWithProviders = RouterModule.forChild(UserConsoleRoutes);
购物车路线:
const ShoppingCartRoutes: Routes = [
{path: '', component:ShoppingCartComponent, redirectTo:'cart', pathMatch:'full'},
{path:'cart', component:CartComponent},
{path:'profile', component:ProfileComponent},
{path:'affiliation', component:AffiliationComponent},
{path:'shipping', component:ShippingComponent},
{path:'payment', component:PaymentComponent},
{path:'confirm', component:ConfirmComponent},
{path:'order-complete', component:OrderCompleteComponent},
];
export const ShoppingCartRouting: ModuleWithProviders = RouterModule.forChild(ShoppingCartRoutes);
但每当我去购物车时,它应该重定向到购物车/购物车,但它会重定向到购物车/我的个人资料
这是我的主app.routing.ts
const appRoutes: Routes = [
{path: '', component: MainComponent},
{path: 'user-register', loadChildren:'app/components/registration/registration.module#RegistrationModule'},
{path: 'registration-confirmation', loadChildren:'app/components/registration-confirmation/registration-confirmation.module#RegistrationConfirmationModule'},
{path: 'login', loadChildren:'app/components/login/login.module#LoginModule'},
{path: 'shopping-cart', loadChildren:'app/components/shopping-cart/shopping-cart.module#ShoppingCartModule'},
{path: 'my-console', loadChildren:'app/components/user-console/user-console.module#UserConsoleModule'},
{path: 'product', loadChildren:'app/components/products/product.module#ProductModule'},
{path: 'enrolment', loadChildren:'app/components/enrolment/enrolment.module#EnrolmentModule'},
{path: 'admin-console', loadChildren:'app/components/admin-console/admin-console.module#AdminConsoleModule'},
export const routing:ModuleWithProviders = RouterModule.forRoot(appRoutes);
我尝试了两个pathMatch:' full'和pathMatch:'前缀'。我不确定我错在哪里。