Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Navigation State #9065


User avatar
0
murat.yuceer created

Hello,

I have problem about navgation extend

For example i have two menu item

new AppMenuItem('Event_Pools', 'Pages.Main.Event.Management.EventPool', 'flaticon2-next', '/app/main/event/management/event-pool/list', ['/app/main/event/management/event-pool/person/list/{event-pool-id}']),

new AppMenuItem('Event_Pools', 'Pages.Main.Event.Management.EventPool', 'flaticon2-next', '/app/main/event/management/event-pool/list', ['/app/main/event/management/event-pool/person/list/{event-pool-id}'], [], null, { eventType: 'Meeting' })

Second menu item have query parameter but when i click menu items, navigation extend both menu items


2 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    I think your use case of matching exact query parameters is generally not appropriate, but you can achieve it as follows.

    app-navigation.service.ts:

    - new AppMenuItem('Event_Pools', 'Pages.Main.Event.Management.EventPool', 'flaticon2-next', '/app/main/event/management/event-pool/list', ['/app/main/event/management/event-pool/person/list/{event-pool-id}']),
    + new AppMenuItem('Event_Pools', 'Pages.Main.Event.Management.EventPool', 'flaticon2-next', '/app/main/event/management/event-pool/list', ['/app/main/event/management/event-pool/person/list/{event-pool-id}'], [], null, {}),
      new AppMenuItem('Event_Pools', 'Pages.Main.Event.Management.EventPool', 'flaticon2-next', '/app/main/event/management/event-pool/list', ['/app/main/event/management/event-pool/person/list/{event-pool-id}'], [], null, { eventType: 'Meeting' })
    

    side-bar-menu.component.ts:

      isMenuItemIsActive(item): boolean {
          ...
    
    -     let urlTree = this.router.parseUrl(this.currentRouteUrl.replace(/\/$/, ''));
    +     let urlTree = this.router.parseUrl(this.router.url);
          let urlString = '/' + urlTree.root.children.primary.segments.map(segment => segment.path).join('/');
          let exactMatch = urlString === item.route.replace(/\/$/, '');
    +     if (exactMatch & item.parameters) {
    +         const itemParamsKeys = Object.keys(item.parameters);
    +         exactMatch = itemParamsKeys.length === Object.keys(urlTree.queryParams).length && itemParamsKeys.every(key => item.parameters[key] === urlTree.queryParams[key]);
    +     }
          ...
          return exactMatch;
      }
    
  • User Avatar
    0
    murat.yuceer created

    Thank you, will you add that next version?