Natixco
Natixco

Reputation: 661

Angular child route in sub outlet

In my TestComponent I have a navbar with the links to multiple components that I want to display in a sub router outlet which is in the TestComponent, but it throws this error.

core.js:6237 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'dashboard/test/id'

const routes: Routes = [
      {
        path: '',
        redirectTo: 'dashboard/test',
        pathMatch: 'full'
      },
      {
        path: 'dashboard',
        children: [
          {
            path: 'test',
            component: TestComponent,
            children: [
              {
                path: '',
                redirectTo: 'id',
                pathMatch: 'full'
              },
              {
                path: 'id',
                component: IdComponent,
                outlet: 'sub'
              }
            ]
          }
        ]
      }
    ];

Upvotes: 0

Views: 119

Answers (1)

John Velasquez
John Velasquez

Reputation: 3451

Your routerLink should be

[routerLink]="['/dashboard/test', {outlets: { sub: ['id'] } }]"

Upvotes: 1

Related Questions