I'm trying to hide the context menu when there is a condition applied. I've come across this post and followed through with it but still, the context menu is showing. I'm trying to add context menu to p-table and I have a condition where if there are no options available then I want to hide context menu but when I'm calling hide() method on context menu it's not working. below are the code snippets of what I did so far.
In .html file
<p-table #table (onContextMenuSelect)="onContextMenuSelect($event, tableContextMenu)" [contextMenu]="tableContextMenu"> </p-table>
<p-contextMenu #tableContextMenu appendTo="body" [model]="contextMenus"></p-contextMenu>
In .ts file
public onContextMenuSelect(event, contextMenu){
if(this.loadContextMenu){
contextMenu.hide();
}
}