sidebar navigation hide after click unless wide screen


Topic: sidebar navigation hide after click unless wide screen

iactor pro asked 6 years ago

Hello,I have a sidebar navigation, I want that if you click on a item, it will close. In every hyperlink i will put the following: (click)=\"sidenav.hide()\" This works great. Now I have somebody with a wide screen, so the sidebar will always be visible. This is no problem to be visible, because there is lots of space. Except now, when the person clicks on a link the sidebar dissapears. But this time I dont want it to happen. What can I do to keep this functionality, but not if somebody has a wide screen? Thanks

Damian Gemza staff answered 6 years ago

Dear iactor, You have to create some method like hideSidenav, and in this method you have to check if window.innerWidth is smaller than your breakpoint. If yes, you have to use sidenav.hide() method. Please take a look at my code:
@ViewChild('sidenav') sidenav: SidenavComponent;

hideSidenav() {

if (window.innerWidth<1440) {

this.sidenav.hide();

}

}
For me it's works like a charm. Best Regards, Damian
Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No