Home > Software design >  Which component renders child component if parent is componentless
Which component renders child component if parent is componentless

Time:11-13

Which component is used to display children components if the parent path does not have any component like in the example below (which component will render ScheduleListComponent component).

const routes: Routes = [
  {
    path: '',  
    children: [
      { path: '', component: ScheduleListComponent },
      { path: 'function/:id', component: ScheduleFunctionComponent },
      { path: 'schedules/:id', component: ScheduleComponent },
    ]
  }
];

CodePudding user response:

Since there is no component assosiated with It wil be rendered in parent router-outlet, normally this pattern is called component less routes.

Componentless routes “consume” URL segments without instantiating components.

Now, when navigating to ’/function/1’, the router will create the following component tree:

AppComponent -> ScheduleFunctionComponent

For more information

  • Related