ps0604
ps0604

Reputation: 1081

Capture double click in ngTable

In this plunk I have an ngTable that shows two rows. I would like to run a function when a row is double clicked. I tried with ng-dblclick but it doesn't work. Any ideas?

HTML

<div ng-controller="myCtl" ng-app="app">
  <table ng-table="tableParams" class="table table-bordered table-hover">
    <tbody>
        <tr ng-repeat="u in data" ng-dblclick="alert('double click')">
            <td title="'User ID'" style="width:150px">{{ u.uid }}</td>
            <td title="'Name'" style="width:150px">{{ u.nm }}</td>
            <td title="'Group'" style="width:200px">{{ u.ugr }}</td>
        </tr>
    </tbody>
</table>

Javascript

var app = angular.module('app', ['ngTable']);

app.controller('myCtl', function($scope,$timeout,NgTableParams) {

  $timeout(function() {

      $scope.data = [ 
        { uid: 'User 1', nm: 'Name 1', ugr: 'Group 1'},
        { uid: 'User 2', nm: 'Name 2', ugr: 'Group 2'}
      ];

      $scope.tableParams = new NgTableParams({dataset: $scope.data});

  }, 1000);

});

Upvotes: 0

Views: 294

Answers (1)

panwar
panwar

Reputation: 1121

I am unable to debug why alert is not working with ng-dblclick. But you can do this by calling a function on ng-dblclick and define that function inside controller.

For eg: (http://plnkr.co/edit/zns8OUA1IuFIcZZkTa1V?p=preview)

Upvotes: 1

Related Questions