The default global settings of the Context menu can be changed using the target attribute (that is, the Context menu will be displayed on other elements other than the global document target). Let's take a Context menu example where the Overlay or popup appears on top of the image element on right-click as shown here:
<p-contextMenu [target]="image" [model]="targetItems" >
</p-contextMenu>
<img #image src="/assets/data/images/primeng.png" alt="Logo">
In this case, both next and previous operations can be performed from the Context menu just by defining the menu items array.