I am using angularjs and populating data in a table using datatable directive. I was able to dispay the data. Now the requirement is add a click event to every row and on click i need to get the row data. How do I add the event listener to dynamically creating rows of data as I haven't worked with directives till now.Unable to find a way.gone through angularjs docs but couldn't find a solution
My directive is
angular.module('SampleApp.directives')
.directive('datatable',
function() {
return {
restrict: 'A',
scope : {
tableData : '='
},
link: function (scope, element, attrs, controller) {
var dataTable = element.dataTable();
dataTable.fnAddData(scope.tableData);
}
}
}
);
The html is
<div style="margin:10px">
<table datatable table-data="organizations">
<thead>
<tr>
<td>Organization Name</td>
<td>Admin</td>
<td>Admin Email</td>
<td>Organization Type</td>
</tr>
</thead>
</table>
</div>