I am trying to create a menu bar recursively using the Angular Material Menu Bar Directive , but the result is not as expected. The best solution that I have so far is to create a directive and call it recursively, as shown here: https://plnkr.co/edit/5pFmmD6K3qz5qolRifVA . Please note that this Plunker has two menu bars. The first one is created with my recursive structure from JSON, and the second one is written directly on the template. The problem with my solution arises when submenus such as "Lorem β Dolor β ..." because the submenus do not align correctly.
Checking the generated code in Chrome, I noticed that the submenu in the second line of the menu (written directly on the template) has some properties regarding the state of its socket:
<md-menu md-position-mode="cascade" class="md-nested-menu md-menu ng-scope" md-nest-level="1"> ... </md-menu>
while in the same menu in the first line of the menu there is no:
<md-menu ng-if="ctrl.isCompoundedMenuItem()" class="md-menu ng-scope"> ... </md-menu>
What can I do to fix this?
Just adding info: I already tried the approach using ng-include to create a menu bar, but the result was terribly worse.
json angularjs angular-material
Frederico pantuzza
source share