如何在Angular 7中将前缀('/ admin')添加到URL路由

时间:2019-09-02 04:32:05

标签: angular routes

我在Angular 7中将路线定义为

 {path: 'register', component: RegisterComponent},
  {path: 'header', component: HeaderComponent, canActivate:  [AuthGuardService]},
  {path: 'footer', component: FooterComponent, canActivate:  [AuthGuardService]},
  {path: 'manage-customer', component: ManageCustomerComponent, canActivate:  [AuthGuardService]},
  {path: 'view-customer', component: ViewCustomerComponent, canActivate:  [AuthGuardService]},
  {path: 'add-merchant', component: AddMerchantsComponent, canActivate:  [AuthGuardService]},
  {path: 'edit-merchant/:id', component: EditMerchantsComponent, canActivate:  [AuthGuardService]},
  {path: 'manage-merchant', component: ManageMerchantsComponent, canActivate:  [AuthGuardService]},
  {path: 'view-merchant/:id', component: ViewMerchantsComponent, canActivate:  [AuthGuardService]},

并且我想在所有网址中添加“ / admin”,使其变得像

{path: '/admin/register', component: RegisterComponent}, {path: '/admin/header', component: HeaderComponent, canActivate: [AuthGuardService]}, {path: '/admin/footer', component: FooterComponent, canActivate: [AuthGuardService]}, {path: '/admin/manage-customer', component: ManageCustomerComponent, canActivate: [AuthGuardService]}, {path: '/admin/view-customer', component: ViewCustomerComponent, canActivate: [AuthGuardService]}, {path: '/admin/add-merchant', component: AddMerchantsComponent, canActivate: [AuthGuardService]}, {path: '/admin/edit-merchant/:id', component: EditMerchantsComponent, canActivate: [AuthGuardService]}, {path: '/admin/manage-merchant', component: ManageMerchantsComponent, canActivate: [AuthGuardService]}, {path: '/admin/view-merchant/:id', component: ViewMerchantsComponent, canActivate: [AuthGuardService]},

我尝试将子级路由添加到/ admin主路由,但是抛出错误。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

创建一个管理父组件并将其放入。然后将所有现有的Routes放在父组件的子组件中。

 <snip>
 10  select * from test t
 11  where (t.id, t.col1, t.col2) not in
 12        (select t1.id, max(t1.col1), max(t1.col2)
 13         from test t1
 14         where t1.id = t.id
 15         group by t1.id, t1.col1
 16        )
 17  order by t.id, t.col1, t.col2;

        ID COL1             COL2
---------- ---------------- ----------------
    123123 2019-07-23 22:00 2019-07-04 00:00
    123123 2019-07-23 22:00 2019-07-05 00:00
    123123 2019-07-25 04:05 2019-07-04 00:00
    123123 2019-07-25 04:05 2019-07-05 00:00

SQL>

这应该可以完成工作。

答案 1 :(得分:-1)

您可以将其用作管理路由的子级

electron-builder