Topic: Subscribing to sidenav overlay click
itay pro asked 6 years ago
How can I Subscribe to sidenav overlay click, for being notified that the sidebar is closing on mobile devices ?
Add comment
itay pro answered 6 years ago
After adding DI for (private renderer: Renderer2, public element: ElementRef) it works
Thanks
Damian Gemza staff answered 6 years ago
So please check this code, maybe this will fit your needs:
Best Regards,
Damian
ngOnInit() { this.renderer.listen(this.el.nativeElement.querySelector('#sidenav-overlay'), 'click', () => { console.log('Overlay clicked'); }); }
Damian Gemza staff answered 6 years ago
Dear mdb2,
There's no possibility to subscribe to sidenav overlay click to check when the sidebar is closing.
But you can achieve similar behavior with HostListener with window:resize event.
Please check my below code:
Maybe it will fit your needs.
We'll think in the future to add such behavior.
Best Regards,
Damian
@ViewChild(SidenavComponent) sidenav: SidenavComponent; @HostListener('window:resize') onresize() { console.log(this.sidenav.shown); }
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Resolved
Specification of the issue
- ForumUser: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: 6.2.2
- Device: NA
- Browser: NA
- OS: NA
- Provided sample code: No
- Provided link: No