ngx-contextmenu icon indicating copy to clipboard operation
ngx-contextmenu copied to clipboard

Is there a way to access markup ng-template content trough @ViewChild()

Open webmatrixxxl opened this issue 6 years ago • 3 comments

Is there a way to access markup of the context-menu template ? I tried to access it trough @ViewChild('myContextMenu') public fileContextMenu; but I can't find anything in the object.

<context-menu #myContextMenu>
  <ng-template contextMenuItem let-item>
    <a>
      <i class="zmdi zmdi-open-in-browser"></i> Open
    </a>
  </ng-template>
  <ng-template contextMenuItem let-item>
    <a data-target="modal-delete">
      <i class="zmdi zmdi-delete"></i>Delete
    </a>
  </ng-template>
</context-menu>

webmatrixxxl avatar Sep 25 '17 15:09 webmatrixxxl

What are you trying to do with the markup? You can view the template for the ContextMenuContentComponent here. It takes care of displaying your context menu items on the page.

isaacplmann avatar Sep 25 '17 15:09 isaacplmann

Ok, I need to do mobile version of the context menu, so I want to reuse the markup I have given. So I need everything in 'ng-template' for the specific menu without opening it.

webmatrixxxl avatar Sep 25 '17 15:09 webmatrixxxl

Looking back at this issue, I think you could accomplish what you want by creating a <context-menu-content> component. Like this:

<context-menu-content [menuItems]="menuItems" [item]="item"></context-menu-content>
menuItems: ContextMenuItemDirective[] = [];
item: any;

isaacplmann avatar Nov 06 '17 21:11 isaacplmann