From bbd86aab0525081ea2e5d8095c478b62af7c066b Mon Sep 17 00:00:00 2001 From: mishkolesnikov Date: Tue, 27 Mar 2018 15:34:45 +0300 Subject: [PATCH] feat(menu): add support for query parameters (#283) (#324) --- e2e/menu.e2e-spec.ts | 14 ++++++++++++++ src/app/menu-test/menu-test.component.ts | 2 ++ .../theme/components/menu/menu-item.component.html | 1 + .../theme/components/menu/menu.component.ts | 2 +- .../theme/components/menu/menu.service.ts | 5 +++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/e2e/menu.e2e-spec.ts b/e2e/menu.e2e-spec.ts index 5a644b673b..5df97b0bc9 100644 --- a/e2e/menu.e2e-spec.ts +++ b/e2e/menu.e2e-spec.ts @@ -276,4 +276,18 @@ describe('nb-menu', () => { expect(browser.getCurrentUrl()).toContain('#/menu/1'); }); }); + + it('should add query string to url', () => { + element.all(menu1).first().click() + .then(() => { + expect(browser.getCurrentUrl()).toContain('param=1'); + }) + }); + + it('should add query string to url (navigate home)', () => { + element(homeButton).click() + .then(() => { + expect(browser.getCurrentUrl()).toContain('param=2'); + }) + }); }); diff --git a/src/app/menu-test/menu-test.component.ts b/src/app/menu-test/menu-test.component.ts index 49a5cccd09..3625544897 100644 --- a/src/app/menu-test/menu-test.component.ts +++ b/src/app/menu-test/menu-test.component.ts @@ -111,6 +111,7 @@ export class NbMenuTestComponent implements OnInit, OnDestroy { title: 'Menu #1', link: '/menu/1', icon: 'nb-keypad', + queryParams: { param: 1 }, }, { title: 'Menu #2', @@ -166,6 +167,7 @@ export class NbMenuTestComponent implements OnInit, OnDestroy { { title: 'Menu #3.3.2', link: '/menu/3/3/2', + queryParams: { param: 2 }, home: true, }, { diff --git a/src/framework/theme/components/menu/menu-item.component.html b/src/framework/theme/components/menu/menu-item.component.html index c122bff4a1..157a22d0f6 100644 --- a/src/framework/theme/components/menu/menu-item.component.html +++ b/src/framework/theme/components/menu/menu-item.component.html @@ -5,6 +5,7 @@