Poornima Satheesh
Poornima Satheesh

Reputation: 187

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?

Upvotes: 4

Views: 4509

Answers (1)

Arnaud Denoyelle
Arnaud Denoyelle

Reputation: 31283

Use event.preventDefault() :

HTML

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

TypeScript

foo($event: MouseEvent) {
  $event.preventDefault();
  /* INSERT CODE HERE */
}

Upvotes: 3

Related Questions