isaacplmann / ngx-contextmenu

An Angular component to show a context menu on an arbitrary component
MIT License
248 stars 91 forks source link

Unable to render nested submenu #240

Open lazaro3487 opened 3 years ago

lazaro3487 commented 3 years ago

Hello.

I am trying to render sub menu by following this approach however it is not working:

<context-menu>
    <ng-container *ngFor="let action of menuEntries">
        <ng-template
            contextMenuItem
            let-item
            [visible]="action.visible"
            [enabled]="action.enabled"
            [divider]="action.divider"
            [subMenu]="subMenu"
            (execute)="action.click($event.item)">
            <div [ngClass]="action.icon"> {{ action.value }}</div>
        </ng-template>

        <context-menu #subMenu>
            <ng-template
                *ngFor="let childAction of action?.children"
                contextMenuItem
                let-item
                [visible]="childAction.visible"
                [enabled]="childAction.enabled"
                [divider]="childAction.divider"
                (execute)="childAction.click($event.item)">
                <div [ngClass]="action.icon"> {{ action.value }}</div>
            </ng-template>
        </context-menu>
    </ng-container>
</context-menu>

It seems like a dynamic nested sub menu does not work.

Do you have any idea on how to accomplish it or maybe it is a bug of the library?