stset stset - 1 year ago 68
jQuery Question

hiding an html section with angularjs on right button click

with angularjs or jquery, how can i hide the html section "sec1" whenever the user right clicks with the mouse inside the canvas area? and show it back again when the user clicks with the left mouse button and viceversa?
i know i can use $event.which but im alittle confused thanks

ng-controller="MainCtrl" background="images.jpe">


oncontextmenu="return false"
id="GLCanvas" width="300" height="200" style="border:2px solid #e3d3d3;">
Your browser does not support the HTML5 canvas.
<b>Total on screen:</b><input type="text" value="0" id="total">
<b>Erase<input type="radio" value="Erase"></b><input type="text" value="0" id="erase">
<section id="sec1">
<css-timer id="idMainControllerTimer"
<div ng-controller="MainCtrl">
<input type="radio" ng-model="mSelection" name="shape" value="Square" ng-change="swap(1)" checked="checked">Square
<input type="radio" ng-model="mSelection" name="shape" value="Circle" ng-change="swap(2)">Circle


Answer Source

You should be able to define an ng-click on the "sec1" section, and act if there was a right-click.

e.g. - on the section add:


And on your controller check if $event.which === 3 and act accordingly (for example, you can set some var $scope.hidden = true and use "ng-if" on that var to remove the "sec1" from the DOM).

Hope that helps.