I need to implement a context menu when I click on a table cell.
I have tried this module which looks nice : https://github.com/ds82/angular-contextmenu
But when I m trying to use it :
    <table class="table table-bordered" contextmenu-container="main.contextmenu">
                    <tbody>
                        <tr ng-repeat="facture in factures"   contextmenu-item="facture">
...
I am getting this error on right click event :
TypeError: undefined is not a function at http://localhost:8080/assets/js/directives/contextmenu.js:74:27
The directive in error is :
app.directive('contextmenuItem', [function() {
  return {
    restrict: 'A',
    require: '^contextmenuContainer',
    scope: false,
    link: function( $scope, $element, $attrs, contextMenuCtrl ) {
      var iam = $scope[( $attrs.contextmenuItem )];
      $element.on( pointerEvents, function( event ) {
        $scope.$apply(function() {
          contextMenuCtrl.open( iam, event );
        });
        event.stopPropagation();
        return false;
      });
    }
  }
}]);
It crashes at this line :
contextMenuCtrl.open( iam, event );
Does anybody uses this module? Is it a known issue?
                        
Currently your problem is you are passing
factureobject inside attribute, which is one of the element, you will never havefacturevariable available inside a scope because it is a part offactures. Thats why when you are doingvar iam = $scope[( $attrs.contextmenuItem )];the value ofiamgets undefined.I'd suggest you to pass use isolated scope as you want to keep a track on the
facturewhich are rendered usingng-repeat, then your isolated scope would havefacture : '='that will passfactureobject to directiveDirective
Your
contextmenuContainerdirective code should be like below.Must have controller associated with that directive and that must contain open method defined in scope.contextmenuContainer Directive