user3747322
user3747322

Reputation: 11

Angular 17 with Nebular Menu - How do I select a menu item when page loads or is refreshed?

I am using Angular 17 and Nebular.

When the user first enters the application or when the page is refereshed, the no select menu item is displeyed. How to do get dynamically select the active menu item?

My sidebar Menu works correctly when user clicks on the menu items.

Thanks

I have looked the api of the NbMenuService but nothing exists here to allow for selection of item.

Upvotes: 1

Views: 127

Answers (1)

user3747322
user3747322

Reputation: 11

I was finally able to figure this out.

There is a 'selected' field on NbMenuItem which you can toggle to make the menu item active.

So by comparing the location url with the nav item link text, you can select the current menu item.

Hope this helps anyone else who gets stuck on this.

Upvotes: 0

Related Questions