ui-grid selection on right click
<p>I want to be able to select the row when there was a right click on the row.</p>

<p>So far I have the following solution (I have the idea from <a href="https://groups.google.com/forum/#!topic/angular/9Gg18uZqGV8" rel="nofollow">here</a>):</p>

<p>I create a right click directive like this:</p>

<pre><code>app.directive('rightClick', function($parse) {
   return function(scope, element, attrs) {
       var fn = $parse(attrs.rightClick);
       element.bind('contextmenu', function(event) {
       scope.$apply(function() {
           event.preventDefault();
               fn(scope, {$event:event});
           });
       });
    };
});
</code></pre>

<p>And then I can add a function in my controller that will be called:</p>

<pre><code> $scope.rightClick = function (event) {
     var scope = angular.element(event.toElement).scope();
     if (scope.row.entity !== undefined) {
         //... select element by calling gridApi
     }
 };
</code></pre>

<p>Adding the directive with the attribute <code>right-click="rightClick($event)"</code> is of course required.</p>

<p>The problem with this solution is that it relies on <code>element.scope()</code> which is a debug feature of angular and will not be available if debug informations are disable in production.</p>

<p>So now I am looking for an alternative solution that works without <code>element.scope()</code>. So the question is: "How can I select the element on right-click without relying on angular debug features".</p>