how to write right click event for selected row in ng-grid using angularjs

Posted by user3819122 on Stack Overflow See other posts from Stack Overflow or by user3819122
Published on 2014-08-22T04:17:24Z Indexed on 2014/08/22 4:20 UTC
Read the original article Hit count: 264

Filed under:
|

i am using angularjs to write click event for selected row from ng-grid.but i want to write right click event for selected row from ng-grid in angularjs.below is my sample code for click event for selected row in ng-grid.

Sample.html:

<html>
<body>
<div ng-controller="tableController">
<div class="gridStyle" ng-grid="gridOptions"></div>
</div>
</body>
</html>

Sample.js:

app.controller('tableController', function($scope) {
      $scope.myData = [{
        name: "Moroni",
        age: 50
      }, {
        name: "Tiancum",
        age: 43
      }, {
        name: "Jacob",
        age: 27
      }, {
        name: "Nephi",
        age: 29
      }, {
        name: "Enos",
        age: 34
      }];
      $scope.gridOptions = {
        data: 'myData',
        enableRowSelection: true,
        columnDefs: [{
            field: 'name',
            displayName: 'Name',
            cellTemplate: '<div  ng-click="foo()" ng-bind="row.getProperty(col.field)"></div>'
          }, {
            field: 'age',
            displayName: 'Age',
           cellTemplate: '<div   ng-click="foo()" ng-bind="row.getProperty(col.field)"></div>'
          }

        ]
      };

     $scope.foo = function() {

       alert('select');
      }
    });

please suggest me how to do this.

© Stack Overflow or respective owner

Related posts about angularjs

Related posts about ng-grid