Как сделать условную маршрутизацию в angular2 - PullRequest
0 голосов
/ 10 декабря 2018

Мне нужно сделать условную маршрутизацию в угловых на основе ключа, но я не понимаю, как это сделать.Может ли кто-нибудь предложить мне путь:

Это текущий сценарий:

const appRoutes: Routes = [

    //Site routes goes here 
    {
        path: 'index/app',
        component: SiteLayoutComponent,
        children: [

            { path: 'onboarding', component: ApplicationFormComponent, canActivate: [AuthGuard] },
            { path: 'onboardingEdit/:appID/:flow/:flowId', component: ApplicationFormEditComponent, canActivate: [AuthGuard] },
            { path: 'equipmentdashboard', component: EquipmentDashboardComponent, canActivate: [AuthGuard] }
        ]

    },

    // App routes goes here here


    {
        path: '',
        component: AppLayoutComponent,
        children: [
            { path: '', component: CarouselComponent, pathMatch: 'full' },
            { path: 'login', component: LoginComponent },
            { path: 'index', component: IndexComponent, canActivate: [AuthGuard] },
            //{ path: 'portallogin', component: PoratlLoginComponent },
        ]
    },



];

Мне нужно сделать условие для Key, как org = "xyz", тогда на компоненте пути ниже будет SiteLayoutComponentвместо AppLayoutComponent

{
            path: '',
            component: SiteLayoutComponent,
            children: [
                { path: '', component: CarouselComponent, pathMatch: 'full' },
                { path: 'login', component: LoginComponent },
                { path: 'index', component: IndexComponent, canActivate: [AuthGuard] },
                //{ path: 'portallogin', component: PoratlLoginComponent },
            ]
        },

Пожалуйста, помогите.

...