Skip to content

p-menu property for binding selected/focused item #2767

Answered by qwadrox
NanobyteRuata asked this question in PrimeNG
Discussion options

You must be logged in to vote

Hi @NanobyteRuata. If you want to use p-menu for navigation, and indicate the currently active route, the best way is to take advantage of the built-in router support: https://primeng.org/menu#router

Here is a tiny demo what to do: https://stackblitz.com/edit/nqyfot-q76ukv?file=src%2Fapp%2Fmenu-router-demo.ts
You can style with the .p-menuitem-link-active class that is being added by the RouterLinkActive directive.
We also have routerLinkActiveOptions to configure how to determine if the router link is active. https://angular.dev/api/router/IsActiveMatchOptions

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by NanobyteRuata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants