Angular4 - 带参数的嵌套路线

时间:2017-08-23 14:45:38

标签: angular angular-routing

我在Angular4中获得了用户配置文件的路由

df.drop_duplicates(subset=['ID'], inplace=True)
df

    ID      Customer    Billing Address Shipping Address    Contact
0   1234    Customer A  123 Street      NaN                 NaN
4   1233    Customer B  444 Street      3335 Street         NaN
7   1235    Customer C  1553 Street     644 Street          abc@email.com

问题是,当我导航到用户/设置时,他尝试打开user /:id ...任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

尝试更改此路线的顺序

{
  path: '', component: FrameDefaultComponent,
  children: [
  {path: 'home', component: SiteHomeComponent},
  {path: 'home/:page', component: SiteHomeComponent},
  {
    path: 'user/settings', component: SiteUserSettingsComponent,
    children: [
      {path: '', redirectTo: 'home', pathMatch: 'full'},
      {path: 'home', component: SiteUserProfileHomeComponent},
      {path: 'about', component: SiteUserProfileAboutComponent}
    ]
  },
  {
    path: 'user/:id', component: SiteUserProfileComponent,
    children: [
      {path: '', redirectTo: 'home', pathMatch: 'full'},
      {path: 'home', component: SiteUserProfileHomeComponent},
      {path: 'about', component: SiteUserProfileAboutComponent}
    ]
  },
  {path: 'demo', component: SiteDemoComponent}
]
},