1

I am trying to find a way to show a specific component when url has only a specific value. Basically this is how is looking the routing now:

const routes: Routes = [
  {
    path: 'users',
    component: MainComponent,
    children: [
      {
        path: ':id',
        component: DashboardComponent,
        children: [
          {
            path: '1',
            component: NeedToRenderThisComponent
          },
          {
            path: '',
            component: DashboardComponent
          },
          {
            path: '',
            outlet: 'sidebar',
            component: SidebarComponent
          }
        ]
      }
    ]
  }
];

So what I am looking for is when user hits or enters another way on '/users/1', user will see NeedToRenderThisComponent. For all others values there will be DashboardComponent.

DashboardComponent contains two router outlets

<router-outlet name="sidebar"></router-outlet>
<router-outlet></router-outlet>

1 Answers1

0

You can use a path: '**' route and then add the component yourself like shown in Angular 2 dynamic tabs with user-click chosen components.

AFAIK there is no way to match values. There were regex routes in an older router but in the current router this is not (yet?) implemented.

update

Support for custom path matchers have landed and will probably be available with the next update https://github.com/angular/angular/issues/12442

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567