0

I'm having troubles with nested routes. Here's my situation:

Routing:

  RouterModule.forRoot([
  {
    path: 'workerevaluation', component: MainComponent, children: [
      {
        path: 'details/:code', component: EmployeeDetailComponent, children: [
          { path: '', component: EmployeeTableComponent },
          { path: 'evaldetail/:evalid', component: EmployeeEvaluationDetailComponent }
        ]
      }
    ]
  },
]),

inside EmployeeTableComponent i have a button with a (click) that should redirect me to the 'evaldetail/:evailid' but it throws me this error:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'https:/localhost:44352/workerevaluation/details/W002/evaldetail/EVAL123'

It seems to not be recognizing the 'details/:code' subpath.

Any suggestion?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

0

With this route config.

RouterModule.forRoot([
  {
    path: 'workerevaluation', component: MainComponent, children: [
      {
        path: 'details/:code', component: EmployeeDetailComponent, children: [
          { path: '', component: EmployeeTableComponent },
          { path: 'evaldetail/:evalid', component: EmployeeEvaluationDetailComponent }
        ]
      }
    ]
  },
]),

You should be having router-outlet in these files.

  1. app.component.html
  2. main.component.html
  3. employee-detail.component.html

Working Stackblitz :- https://stackblitz.com/edit/angular-ymomja

Note in the stackblitz browser append this after url :- /workerevaluation/details/W002/evaldetail/EVAL123

Aakash Garg
  • 10,649
  • 2
  • 7
  • 25