【问题标题】:conditional redirect different layout angular 4条件重定向不同的布局角度4
【发布时间】:2018-04-30 16:21:31
【问题描述】:

我的项目中有两个布局。一个是Basiclayout,另一个是Locationlayout。当用户第一次访问网站时,他是在 Basiclayout 中,但是当他给出他的位置时,布局将是 Locationlayout。如何根据这种情况在我的 app-routing.module.ts 文件中重定向?

我的 app-routing.module.ts 的代码 sn-p:-

const routes: Routes = [

    { 
    path: '',
    component: BasiclayoutComponent, 
    children: [
      { path: '', component: HomeComponent },

    ]
  },
  { 
    path: '',
    component: LocationlayoutComponent, 
    children: [
      { path: '', component: HomeComponent },

    ]
  }
];

【问题讨论】:

  • 谁能给我一个建议?

标签: angular angular4-router


【解决方案1】:

你可以试试这样的。

const routes: Routes = [

    { 
    path: '',
    component: BasiclayoutComponent, 
    children: [
      { path: 'home', component: HomeComponent },

    ]
  },
  { 
    path: 'location',
    component: LocationlayoutComponent, 
    children: [
      { path: 'home', component: HomeComponent },

    ]
  }
];

基础首页:http://localhost:4200/home 位置首页:http://localhost:4200/location/home

【讨论】:

    猜你喜欢
    • 2018-08-22
    • 2014-07-19
    • 2018-04-17
    • 2018-10-09
    • 2018-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-15
    相关资源
    最近更新 更多