Page 1 of 1

Keep menu-item expanded after click

Posted: 14 May 2021, 20:26
by piedfork
Hi, I'm using angular and freya v10. I've a left side menu with 2 levels which is working correctly. But when I click on a submenu the parent menu-item is collapsed. Is there a possibility to keep the parent menu-item open?

Re: Keep menu-item expanded after click

Posted: 14 May 2021, 23:23
by merve7
Hi,
Could you check your parent route links, like;

Code: Select all

{
    label: 'UI Kit', icon: 'pi pi-fw pi-star', routerLink: ['/uikit'],
    items: [
        {label: 'Form Layout', icon: 'pi pi-fw pi-id-card', routerLink: ['/uikit/formlayout']},
        //other routes
}
Also, your code must contain constructor, ngOnInit and updateActiveStateFromRoute() function parts in app.menuitem.component.ts file.

Re: Keep menu-item expanded after click

Posted: 15 May 2021, 15:59
by piedfork
Hi

Thanks for the reply, my issue was indeed the routerlink.
The path of the submenu must begin with the part of the parent. Like in your example /uikit, this was not the case in my code. Now it works.

thanks.

Re: Keep menu-item expanded after click

Posted: 18 May 2021, 15:48
by merve7
Glad to hear :)