1

I am integrating SB Admin2 template with my angular 7 project.But any link in the sidebar is not working. Even they are not clickable totally. But if put a router link in body wrapper it works as it should.

I have already tried using [routerlink] instead of routerlink.I have added routermodule in appmodule note: the router links are in index.html file

<li class="nav-item">
  <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
    <i class="fas fa-fw fa-cog"></i>
    <span>Components</span>
  </a>
  <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
    <div routerLink="/add" class="bg-white py-2 collapse-inner rounded">
      <h6 class="collapse-header">Custom Components:</h6>
      <a class="nav-link" routerLink="/add">Buttons</a>
    </div>
  </div>
</li>

1 Answers1

2

I think (not absolutely 100% sure) that you cannot use the [routerLink] inside the "index.html" file, but only inside components/templates.
Anyway I think you should consider creating a new component, for instance "app-page-sidebar", and cut/paste your sidebar html code from "index.html" to this new component template "page-sidebar.component.html".
Finally rearange your page in your "app-root" component "app.component.html" to match the desired page structure (<app-page-sidebar></app-page-sidebar> <router-outlet></router-outlet>)
It's modular and I guarantee that the [routerLink] will work inside this new component.

antseq
  • 191
  • 9