2

I have a situation where, I want a resolver if the child route is a param, and not if it's a path segment. Below is my code.

{
    path: 'agreement',
    children: [
      {
        path: ':id',
        component: AgreementComponent,
        resolve: { agreementDetails: AgreementDetailsResolveService }
      },
      {
        path: 'create',
        component: AgreementComponent
      }
    ]
  }

When I hit the path agreement/create, it's throwing error, as create is considered as the value of the param id and it's invalid.

Please help me with this.

karthikaruna
  • 3,042
  • 7
  • 26
  • 37

1 Answers1

3

Rearrange your route definition:

{
    path: 'agreement',
    children: [
      {
        path: 'create',
        component: AgreementComponent
      },
      {
        path: ':id',
        component: AgreementComponent,
        resolve: { agreementDetails: AgreementDetailsResolveService }
      }
    ]
  }
asmmahmud
  • 4,844
  • 2
  • 40
  • 47