Skip to content

Investigate/implement automatic route tree #11

@Wolfr

Description

@Wolfr

Investigate the possibility of an automatic route tree.

Currently, we have a template that looks like this prototype-wrapper.component.html:

        <li>
          <h4 class="br-styleguide-bordered-list-header">Documentation</h4>
          <ul class="br-styleguide-bordered-list">
            <li>
              <a routerLink="/sign-in">Sign in</a>
            </li>
            <li>
              <a routerLink="/dashboard">Dashboard</a>
            </li>
          </ul>
        </li>
...(code abbreviated)

There is also routing data in app-routing.module.ts:


const routes: Routes = [
  { path: 'sign-in', component: SignInComponent },
  { path: 'styleguide', component: StyleguideComponent },
  { path: '', redirectTo: '/sign-in', pathMatch: 'full' },
  {
    path: 'dashboard', component: DashboardComponent,
    children: [
      { path: 'module-1', component: ModuleOneComponent },
      { path: 'module-2', component: ModuleTwoComponent },
      { path: 'module-3', component: ModuleThreeComponent },
    ]
  },
  {
    path: 'styleguide', component: StyleguideComponent,
    children: [
      { path: 'colors', component: ColorsComponent },
      { path: 'typography', component: TypographyComponent },
      { path: 'icons', component: IconsComponent },
      { path: 'button-skins', component: ButtonSkinsComponent },
    ]
  },
];

Can we somehow use this to create a loop to loop over our tree? I crafted some non-working code as an example:

<li *ngFor="let route of routes"
  [class.selected]="route === activeRoute"
>
<a href="{{route.path}}">
{{route.name}}
</a>
</li>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions