0

我将 ngx-contextmenu 用于右键单击菜单,并在 contextmenu 中为某些菜单设置子菜单(基于 ngx-contextmenu 站点实现子菜单)。

<context-menu>
  <ng-template contextMenuItem [subMenu]="saySubMenu">
    Say...
  </ng-template>
  <context-menu #saySubMenu>
    <ng-template contextMenuItem (execute)="showMessage('Hi, ' + $event.item.name)">
      ...hi!
    </ng-template>
    <ng-template contextMenuItem (execute)="showMessage('Hola, ' + $event.item.name)">
      ...hola!
    </ng-template>
    <ng-template contextMenuItem (execute)="showMessage('Salut, ' + $event.item.name)">
      ...salut!
    </ng-template>
   </context-menu>
   <ng-template contextMenuItem divider="true"></ng-template>
   <ng-template contextMenuItem let-item (execute)="showMessage($event.item.name + ' said: ' + $event.item.otherProperty)">
Bye, {{item?.name}}
   </ng-template>
   <ng-template contextMenuItem passive="true">
      Input something: <input type="text">
   </ng-template>
 </context-menu>

我想在打开时以编程方式关闭子菜单(saySubMenu)。
我使用波纹管代码但不起作用:

saySubMenu.close.next({
        eventType: 'cancel'
    });

如何关闭只打开子菜单?

4

0 回答 0