angular routing multiple paths to same component

前端 未结 3 1523
时光说笑
时光说笑 2020-12-15 22:25

Is there a way to optimize this code from this

{
  path: \'access-requests\',
  canActivate: [AccessGuard],
  component: AccessRequestsComponent,
  children:         


        
3条回答
  •  庸人自扰
    2020-12-15 23:09

    You can use a mapped array:

    children: [
      // excluding the other paths for brevity
      ...['today', 'tomorrow', 'expired'].map(path => ({
        path,
        component: AccessRequestsComponent
      }))
    ]
    

提交回复
热议问题