From b8d5c16237ed8c344e96987716f20faf92210f61 Mon Sep 17 00:00:00 2001 From: mustafahlvc Date: Fri, 18 Aug 2017 16:44:39 +0300 Subject: [PATCH] (fuseNavBar) close on route change for mobile. --- src/app/main/navbar/navbar.component.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/app/main/navbar/navbar.component.ts b/src/app/main/navbar/navbar.component.ts index cc2ee634..f813570e 100644 --- a/src/app/main/navbar/navbar.component.ts +++ b/src/app/main/navbar/navbar.component.ts @@ -4,6 +4,7 @@ import { FuseMatchMedia } from '../../core/services/match-media.service'; import { FuseNavbarService } from './navbar.service'; import { ObservableMedia } from '@angular/flex-layout'; import { FuseMainComponent } from '../main.component'; +import { NavigationEnd, Router } from '@angular/router'; @Component({ selector : 'fuse-navbar', @@ -25,7 +26,8 @@ export class FuseNavbarComponent implements OnInit, OnDestroy private fuseMainComponentEl: FuseMainComponent, private fuseMatchMedia: FuseMatchMedia, private navBarService: FuseNavbarService, - public media: ObservableMedia + public media: ObservableMedia, + private router: Router ) { navBarService.setNavBar(this); @@ -46,6 +48,20 @@ export class FuseNavbarComponent implements OnInit, OnDestroy } }); }); + + router.events.subscribe( + (event) => { + if ( event instanceof NavigationEnd ) + { + if ( this.media.isActive('lt-lg') ) + { + setTimeout(() => { + this.closeBar(); + }); + } + } + } + ); } ngOnInit()