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
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
You can use routerLink for this yes.
@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.
Merged PR, thanks.
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
Most helpful comment
@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.