Topic: Navbar does not close on link click

Hello, my navbar does not auto close when link is clicked. Adding [routerLink]="['/']" does not help. How can I fix this? Thanks! My html component is:
<mdb-navbar SideClass="navbar navbar-expand-lg navbar-dark fixed-top scrolling-navbar">
 <links>
 <ul class="nav navbar-nav ml-auto w-100 justify-content-end">
 <li class="nav-item waves-light" mdbRippleRadius>
 <a [routerLink]="['/']" class="nav-link" [ngx-scroll-to]="'#section-1'">Usluge</a>
 </li>
 <li class="nav-item waves-light" mdbRippleRadius>
 <a [routerLink]="['/']" class="nav-link" [ngx-scroll-to]="'#section-3'">Kako radimo</a>
 </li>
 <li class="nav-item waves-light" mdbRippleRadius>
 <a [routerLink]="['/']" class="nav-link" [ngx-scroll-to]="'#section-6'">Kako ne radimo</a>
 </li>
 <li class="nav-item waves-light" mdbRippleRadius>
 <a [routerLink]="['/']" class="nav-link" [ngx-scroll-to]="'#section-7'">Kontakt</a>
 </li>
 </ul>
 </links>
</mdb-navbar>


Dear Damian!   I made the most vanilla mistake!!! I forgot to:
import { RouterModule } from '@angular/router';
in app.module.ts and add to the imports array:
RouterModule.forRoot([
{ path: '', component: AppComponent}
])
Now it works beautifully!!!!
My fault all the way!
Thanks for your quick response! Cheers!!!!

Damian Gemza staff commented 4 years ago

Glad that everything is working fine to you! Best Regards, Damian

Damian Gemza staff answered 4 years ago


Dear Vladislav, do browser console throws you any errors? Do you test it in mobile or normal desktop view of navbar? Please try to change [routerLink]="['/']" to routerLink="/". Maybe this will help you. Best Regards, Damian

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Closed

Specification of the issue

  • User: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags