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:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
@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.