question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add dynamic child menu items for a menu

See original GitHub issue
  • V3.2.?
  • Your base framework: .Net Core.
  • Steps needed to reproduce the problem.

suppose the menu like this:

menuItems: MenuItem[] = [
        new MenuItem(this.l("HomePage"), "", "home", "/app/home"),
        new MenuItem(this.l("Administration"), "Pages.Entities", "view_module", ""),
        new MenuItem(this.l("Tenants"), "Pages.Tenants", "business", "/app/tenants"),
        new MenuItem(this.l("Users"), "Pages.Users", "people", "/app/users"),
        new MenuItem(this.l("Roles"), "Pages.Roles", "local_offer", "/app/roles"),
        new MenuItem(this.l("About"), "", "info", "/app/about"),
    ];

If I assign a new items to the administration menu(the items is null), a click on the menu item will not expand the sub menu items even the page already have the ‘+’. now change the menu to new MenuItem(this.l("Administration"), "Pages.Entities", "view_module", "", []), if I then add each child menus into this items, click on the menu can expand the sub menu.

I did this in the ngOnInit() of the SideBarNavComponent of the \src\app\layout\sidebar-nav.component.ts

if(this.menuItems[1].items === null){
this.menuItems[1].items = [];
}
this.menuItems[1].items,push(new MenuItem(...));

this doesn’t bring me the expand.

please help. Thanks, Jason.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonliaocncommented, Jun 1, 2018

@ismcagdas Thanks for your update and the issue was fixed after I load my dynamic staff in the appSession then init the menuitem in the ngOnInit function.

0reactions
ismcagdascommented, May 2, 2018

@jasonliaocn please apply changes in the below commit into your project. https://github.com/aspnetboilerplate/module-zero-core-template/commit/e3b3ca34acb9a36ac9f4f5ce3270e617ac90b03c

Then, you can add new menu items in ngOnInit dynamically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material Menu - Nested Menu using Dynamic Data
The Angular Material Menu is a floating panel containing a list of options. In this tutorial, we will learn how we can create...
Read more >
Dynamic nested Material menu from json object in Angular 5
I started using Angular Material Design today for the first time and I'm trying to create nested menus using material design. The documentation ......
Read more >
Use wp_nav_menu to dynamically generate child menus
The goal: use wordpress's wp_nav_menu to generate a menu where child pages were dynamically added while keeping the correct submenu classes.
Read more >
Dynamically Adding Menu Items - Visual Studio (Windows)
You can add menu items at run time by specifying the DynamicItemStart command flag on a placeholder button definition in the Visual Studio ......
Read more >
Creating Dynamic Menu items
Destroy any existing dynamic child menu items. Add the new dynamic menu items by creating the new menu item object and adding it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found