如何在angular2中进行条件路由

时间:2018-12-10 07:30:12

标签: angular2-routing

我需要在一个键的基础上进行有角度的条件路由,但我没有得到如何做。谁能建议我这样的方式:

这是当前方案:

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 },
        ]
    },



];

我需要以org =“ xyz”之类的Key为条件,然后在下面的路径组件上将使用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 },
            ]
        },

请帮助。

0 个答案:

没有答案