From 2d60a286d258194f98641e90186b0659176f0f3d Mon Sep 17 00:00:00 2001 From: Grzegorz Rozdzialik Date: Wed, 21 Sep 2016 22:55:23 +0200 Subject: [PATCH] feat(menu): highlight childless items when path matches --- src/app/theme/components/baMenu/baMenu.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/theme/components/baMenu/baMenu.service.ts b/src/app/theme/components/baMenu/baMenu.service.ts index 245da3ed..f4839dbb 100644 --- a/src/app/theme/components/baMenu/baMenu.service.ts +++ b/src/app/theme/components/baMenu/baMenu.service.ts @@ -100,6 +100,7 @@ export class BaMenuService { object.url = object.url ? object.url : '#' + itemUrl; object.target = object.target || ''; + object.pathMatch = object.pathMatch || 'full'; return this._selectItem(object); } @@ -107,7 +108,11 @@ export class BaMenuService { } protected _selectItem(object:any):any { - object.selected = object.url == ('#' + this._router.url); + if (object.children || object.pathMatch === 'full') { + object.selected = object.url === ('#' + this._router.url); + } else { + object.selected = ('#' + this._router.url).indexOf(object.url) === 0; + } return object; } }