Skip to content

Commit

Permalink
feat(menu): support more navigation extras (#2420)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdubb committed Sep 17, 2020
1 parent 9ac12c7 commit 03aabfa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/framework/theme/components/menu/menu-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[routerLink]="menuItem.link"
[queryParams]="menuItem.queryParams"
[fragment]="menuItem.fragment"
[queryParamsHandling]="menuItem.queryParamsHandling"
[preserveFragment]="menuItem.preserveFragment"
[skipLocationChange]="menuItem.skipLocationChange"
[attr.target]="menuItem.target"
[attr.title]="menuItem.title"
Expand Down
10 changes: 8 additions & 2 deletions src/framework/theme/components/menu/menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
PLATFORM_ID,
} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { Router, NavigationEnd } from '@angular/router';
import { Router, NavigationEnd, NavigationExtras } from '@angular/router';
import { BehaviorSubject, Subject } from 'rxjs';
import { takeUntil, filter, map } from 'rxjs/operators';
import { NbMenuInternalService, NbMenuItem, NbMenuBag, NbMenuService, NbMenuBadgeConfig } from './menu.service';
Expand Down Expand Up @@ -354,7 +354,13 @@ export class NbMenuComponent implements OnInit, AfterViewInit, OnDestroy {

if (homeItem) {
if (homeItem.link) {
this.router.navigate([homeItem.link], { queryParams: homeItem.queryParams, fragment: homeItem.fragment });
const extras: NavigationExtras = {
queryParams: homeItem.queryParams,
queryParamsHandling: homeItem.queryParamsHandling,
fragment: homeItem.fragment,
preserveFragment: homeItem.preserveFragment,
};
this.router.navigate([homeItem.link], extras);
}

if (homeItem.url && isPlatformBrowser(this.platformId)) {
Expand Down
4 changes: 3 additions & 1 deletion src/framework/theme/components/menu/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Injectable } from '@angular/core';
import { Location } from '@angular/common';
import { Params } from '@angular/router';
import { Params, QueryParamsHandling } from '@angular/router';
import { Observable, BehaviorSubject, ReplaySubject, Subject } from 'rxjs';
import { share } from 'rxjs/operators';
import { isFragmentContain, isFragmentEqual, isUrlPathContain, isUrlPathEqual } from './url-matching-helpers';
Expand Down Expand Up @@ -105,10 +105,12 @@ export class NbMenuItem {
*@type {Params}
*/
queryParams?: Params;
queryParamsHandling?: QueryParamsHandling;
parent?: NbMenuItem;
selected?: boolean;
data?: any;
fragment?: string;
preserveFragment?: boolean;

/**
* @returns item parents in top-down order
Expand Down

0 comments on commit 03aabfa

Please sign in to comment.