From 17d38d59a6f4011ee6f0b85cd4f5c83910cbd18c Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 12 Apr 2021 15:35:49 +0000 Subject: [PATCH] [Library | Trunk]: NavBar fix current route on html git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60841 d315682c-612b-4755-9ff5-7f18f6832af3 --- sharedComponents/navigationBar.component.html | 4 ++-- sharedComponents/navigationBar.component.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sharedComponents/navigationBar.component.html b/sharedComponents/navigationBar.component.html index 0a7750ab..15dc698d 100644 --- a/sharedComponents/navigationBar.component.html +++ b/sharedComponents/navigationBar.component.html @@ -74,7 +74,7 @@ -
  • +
  • Home
  • -->
      -
    • +
    • Home
    • diff --git a/sharedComponents/navigationBar.component.ts b/sharedComponents/navigationBar.component.ts index c72464e9..5715aae6 100644 --- a/sharedComponents/navigationBar.component.ts +++ b/sharedComponents/navigationBar.component.ts @@ -147,6 +147,13 @@ export class NavigationBarComponent implements OnInit, OnDestroy { console.error('NavigationBar (component): ' + message, error); } + get currentRoute() { + return { + route: this.router.url.split('?')[0].split('#')[0], + fragment: this.route.snapshot.fragment + } + } + isTheActiveMenu(menu: RootMenuItem): boolean { if (!menu.rootItem.markAsActive) { return false; @@ -164,10 +171,7 @@ export class NavigationBarComponent implements OnInit, OnDestroy { } isTheActiveMenuItem(menuItem: MenuItem): boolean { - let currentRoute = { - route: this.router.url.split('?')[0].split('#')[0], - fragment: this.route.snapshot.fragment - }; + let currentRoute = this.currentRoute; return (menuItem.route == currentRoute.route || menuItem.route == (currentRoute.route + "/")) && currentRoute.fragment == menuItem.fragment; }