ngx-contextmenu
ngx-contextmenu copied to clipboard
Is there a way to access markup ng-template content trough @ViewChild()
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>
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.
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.
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;