Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add queryParam support to MenuItem. #1939

Closed
johnhwright opened this issue Jan 27, 2017 · 5 comments
Closed

Add queryParam support to MenuItem. #1939

johnhwright opened this issue Jan 27, 2017 · 5 comments
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@johnhwright
Copy link

johnhwright commented Jan 27, 2017

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[X] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
No way to include queryParams in menu item..

Expected behavior

export interface MenuItem {
    label?: string;
    icon?: string;
    command?: (event?: any) => void;
    url?: string;
    routerLink?: any;
    queryParams?: { [k: string]: any }; // Add this.
    eventEmitter?: EventEmitter<any>;
    items?: MenuItem[];
    expanded?: boolean;
    disabled?: boolean;
}

The primeNg menu component would send the queryParams in the ItemClick handler.

Minimal reproduction of the problem with instructions
Try and use queryParams with a menu item.

What is the motivation / use case for changing the behavior?
Seems strange to include have routerLink without the ability to add queryParams.
With this addition in ultima's layout menu we could also now do this:

{
  label: 'Link', icon: 'card_membership',
  routerLink: ['/some/route],
  queryParams: { foo: [1, 2, 3], bar: new Date() },
},

Note for anyone using ultima you would also need to update the sub-menu.component template:
<a (click)="itemClick($event,child,i)" class="ripplelink" *ngIf="child.routerLink" [routerLink]="child.routerLink" [queryParams]="child.queryParams" routerLinkActive="active-menuitem-routerlink"

Please tell us about your environment:

  • Angular version: 2.0.X
    2.4.5

  • PrimeNG version: 2.0.X
    2.0.0-rc.1

@abrarShariar
Copy link

I am also facing a similar issue of passing queryParms. A workaround could be -

{
  label: item.label,
  routerLink: [route, {param: slug}]
}

Current behavior
The above code produces this url - /route;param=slug

Expected behaviour
/route?param=slug

Environment

  • Angular version: 4.0.X
    4.0.0

  • PrimeNG version: 4.0.X
    4.0.1

@cagataycivici
Copy link
Member

You can use routerLink for this yes.

@johnhwright
Copy link
Author

@cagataycivici - routerLink is only capable of adding matrix params. You need to set the queryParams attribute.

I included all the code that's needed in the original post.

@cagataycivici cagataycivici self-assigned this Oct 25, 2017
@cagataycivici cagataycivici added the Type: New Feature Issue contains a new feature or new component request label Oct 25, 2017
@cagataycivici cagataycivici added this to the 4.3.0 milestone Oct 25, 2017
@cagataycivici
Copy link
Member

Merged PR, thanks.

@Wendkouny
Copy link

Note for anyone using ultima you would also need to update the sub-menu.component template:
<a (click)="itemClick($event,child,i)" class="ripplelink" *ngIf="child.routerLink" [routerLink]="child.routerLink" [queryParams]="child.queryParams" routerLinkActive="active-menuitem-routerlink"

very usefull, I'am using ultima and the quoted part of your response saved me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

4 participants