Hi,
I am trying to clear all the items from the Menu, unfortunately, in the NbMenuService I have only the addItems, but I am looking for a clear or replace method.
Can you help me please?
Regards,
Hi @misterfifi1, as I see your issue properly, you just need to pass new menu items array in <nb-menu [items]="newMenuItems"></nb-menu>
Thanks,
I will try but I will have to act on directly on the HTML, it would be better to implement the method :)
Regards,
Hello,
Sorry, but when I try to empty the nb-menu with innerHTML the new menu is not generated. Do you have another solution for dynamic menu?
Thanks.
Hi @misterfifi1. You don't have to remove DOM nodes. Instead you can set property used in menu items binding to empty array. See example.
that's great and all if you are in the same component. But that is going to become a bit tricky if you are in a different component(s).
Having a clear function in the NbMenuService would be great!
Hi,
Honestly I had to change the UX due to this missing feature, I wanted a dynamic menu triggered by another component.
If you can add this feature if would be very appreciated!
that's great and all if you are in the same component. But that is going to become a bit tricky if you are in a different component(s).
Having a clear function in the NbMenuService would be great!
Ah, I found a way to do the tricky thing not so tricky.
If you have your menu setup the same way as in the starter-kit. You can import the variable MENU_ITEMS and set the length to 0 to clear it.
Thanks a lot!
I will test that, quickly, but it should be better to have that handled by the framework :)
Any updates on this?
I need similar functionality but seems NbMenuService still does not support it.
Does anyone have a solution for this??
Most helpful comment
that's great and all if you are in the same component. But that is going to become a bit tricky if you are in a different component(s).
Having a clear function in the NbMenuService would be great!