Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent default context menu in angular7

In my Angular project I use an angular data-table and created a context menu. But when clicking on it the default right click option also appears with the created context menu. How can I prevent a default right click action in Angular?

like image 516
Poornima Satheesh Avatar asked Sep 19 '25 00:09

Poornima Satheesh


1 Answers

Use event.preventDefault() :

HTML

<div (contextmenu)="foo($event)">
  [...]
</div>

TypeScript

foo($event: MouseEvent) {
  $event.preventDefault();
  /* INSERT CODE HERE */
}
like image 93
Arnaud Denoyelle Avatar answered Sep 20 '25 16:09

Arnaud Denoyelle