I try to make the div
editable but the first attempt does not work, then if it works, what is the error?
try it out by clicking on the phrase
var app = angular.module('plunker', []);
app.directive('rightClick', function() {
document.oncontextmenu = function(e) {
if (e.target.hasAttribute('right-click')) {
return false;
}
}
return function(scope, el, attrs) {
el.bind('contextmenu', function(e) {
document.getElementById('op').contentEditable = 'true';
});
}
});
app.controller('MainCtrl', function($scope) {
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>
<script src="app.js"></script>
<body ng-app="plunker" ng-controller="MainCtrl">
<div id="op" right-click alert="You right clciked me">Right click me</div>
</body>