user944513
user944513

Reputation: 12729

How to get row click event in angular?

I am trying get row object selected with row click event. I am using Angular UI Grid

Here is the API link http://ui-grid.info/docs/#/tutorial/103_filtering

I used this to get the data:

    enableRowSelection: true,
        multiSelect:false,
        onRegisterApi : function(gridApi){
  //set gridApi on scope
  $scope.gridApi = gridApi;
  gridApi.selection.on.rowSelectionChanged($scope,function(row){
    var msg = 'row selected ' + row.isSelected;
    $log.log(msg);
  });

Here is my code https://plnkr.co/edit/DqBgHFnwLpYM5pvg0f56?p=preview

Upvotes: 0

Views: 1383

Answers (1)

cuongle
cuongle

Reputation: 75316

Inject ui.grid.selection into your app module:

angular.module('app',['ngTouch', 'ui.grid', 'ui.grid.selection'])

Setup selection on html:

<div id="grid1" ui-grid="gridOptions" ui-grid-selection class="grid" ></div>

Get selected row object using row.entity:

 gridApi.selection.on.rowSelectionChanged($scope,function(row){
    var msg = 'row selected ' + row.entity.age;
    console.log(msg);
  });

Working plunker:

https://plnkr.co/edit/fxtD3F4iFxmPKT1G1t7V

Upvotes: 1

Related Questions