Issue
In Angular is there a way to catch right click events? I see (click) and (dblclick), but when I try (rightclick) it does not trigger any events. Is there a way to include right click events and have them be handled by a function similar to the click and dblclick if it does not exist?
Solution
The event name is contextmenu. So, your html template code can be something like this:
<div (contextmenu)="onRightClick($event)"></div>
$event is an optional parameter so your template and event handler can look like this:
<div (contextmenu)="onRightClick()"></div>
onRightClick() {
return false;
}
NOTE: You can return false; to avoid default browser action from the event.
Answered By - Zzz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.