#angular #angular2-routing
#angular #angular2-маршрутизация
Вопрос:
У меня есть два родительских компонента: консоль пользователя и корзина покупок.
Для них используются маршруты 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);
Но всякий раз, когда я захожу в корзину покупок, он должен перенаправляться в корзину покупок / корзину, но перенаправляется в корзину покупок / мой профиль
Вот мое основное приложение.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:’prefix’. Я не совсем уверен, где я ошибаюсь.