Issue
<div class="container" (contextmenu)="onRightClick()">
</div>
I want to disable right click in a few components and not the whole website. I have to define the below function in all the components where I want to disable right click. What's the best way to do it so that I don't have to define the function again and again in those components
onRightClick() {
return false;
}
Solution
It's the contextmenu event : create a directive to manage that.
@HostListener('contextmenu', ['$event'])
onRightClick(event) {
event.preventDefault();
}
Answered By - user4676340
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.