I have the directive from angular smart table for adding a checkbox selection to the rows of the table shown below. I want to be able to execute a custom function when I click on the checkbox. Is this possible ? I basically need to store the rowid or another property of the rows when the checkbox is clicked.
app.directive('csSelect', function () {
return {
require: '^stTable',
template: '<input type="checkbox"/>',
scope: {
row: '=csSelect'
},
link: function (scope, element, attr, ctrl) {
element.bind('change', function (evt) {
scope.$apply(function () {
ctrl.select(scope.row, 'multiple');
});
});
scope.$watch('row.isSelected', function (newValue, oldValue) {
if (newValue === true) {
element.parent().addClass('st-selected');
} else {
element.parent().removeClass('st-selected');
}
});
}
};
});
EDIT
The way this directive is used as follows:
<td cs-select="row"></td>
note that if I add ng-click to the td element to check for a clicked row, it does not matter whether I click on the checkbox. As soon as I click anywhere inside the td element, it acts as that I clicked on the row. So that's not a solution