Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate/implement automatic route tree #11

Open
Wolfr opened this issue Jun 24, 2020 · 1 comment
Open

Investigate/implement automatic route tree #11

Wolfr opened this issue Jun 24, 2020 · 1 comment

Comments

@Wolfr
Copy link
Contributor

Wolfr commented Jun 24, 2020

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>
@Wolfr
Copy link
Contributor Author

Wolfr commented Jun 25, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant