From 0d8fe0be729d32c2ed80c19b8f85ca8d5eb3c648 Mon Sep 17 00:00:00 2001 From: Sercan Yemen Date: Thu, 30 Nov 2017 10:37:35 +0300 Subject: [PATCH] Trigger expand/collapse of the navigation on ngOnInit to update the active item --- .../nav-vertical-collapse.component.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/core/components/navigation/vertical/nav-collapse/nav-vertical-collapse.component.ts b/src/app/core/components/navigation/vertical/nav-collapse/nav-vertical-collapse.component.ts index af40fa3b..31712d66 100644 --- a/src/app/core/components/navigation/vertical/nav-collapse/nav-vertical-collapse.component.ts +++ b/src/app/core/components/navigation/vertical/nav-collapse/nav-vertical-collapse.component.ts @@ -69,6 +69,20 @@ export class FuseNavVerticalCollapseComponent implements OnInit ); } + ngOnInit() + { + // Check if the url can be found in + // one of the children of this item + if ( this.isUrlInChildren(this.item, this.router.url) ) + { + this.expand(); + } + else + { + this.collapse(); + } + } + /** * Toggle collapse * @@ -108,6 +122,7 @@ export class FuseNavVerticalCollapseComponent implements OnInit { return; } + this.isOpen = false; this.navigationService.onNavCollapseToggle.emit(); } @@ -175,8 +190,4 @@ export class FuseNavVerticalCollapseComponent implements OnInit return false; } - ngOnInit() - { - } - }