Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Reinitialize SideNav Component

marketingtech priority asked 5 years ago


We're trying to dynamically create a sidenav menu based on a users role and access to sections of our site. Is there a way to reinitialize the sidenav component once we've created the menu and append it to the DOM?

Right now when we append a menu item to the DOM (in AfterViewInit), none of the interaction is added it. The two dashboard items in the screenshot were generated with the same markup. The only difference is that the first one is part of the component and the second was added dynamically.

Code sample: https://mdbootstrap.com/snippets/jquery/clareaza7/1555773?action=forum_snippet

enter image description here


Arkadiusz Idzikowski staff commented 5 years ago

You added the code to the jQuery snippet, the Angular code won't work there. Does this problem occur in your Angular application as well?

You can use ngIf directive to hide the accordion element. It won't be added to the DOM until you update the boolean variable added to the directive.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: 8.8.0
  • Device: Desktop
  • Browser: Chrome
  • OS: Windows/Mac
  • Provided sample code: No
  • Provided link: Yes