Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 042684b

Browse files
committed
RenderWith with data object in ng-click #145
1 parent 5488f98 commit 042684b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

demo/advanced/bindAngularDirective.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function BindAngularDirectiveCtrl($scope, $compile, DTOptionsBuilder, DTColumnBu
88
vm.edit = edit;
99
vm.delete = deleteRow;
1010
vm.dtInstance = {};
11+
vm.persons = {};
1112
vm.dtOptions = DTOptionsBuilder.fromSource('data1.json')
1213
.withPaginationType('full_numbers')
1314
.withOption('createdRow', createdRow);
@@ -19,14 +20,14 @@ function BindAngularDirectiveCtrl($scope, $compile, DTOptionsBuilder, DTColumnBu
1920
.renderWith(actionsHtml)
2021
];
2122

22-
function edit(id) {
23-
vm.message = 'You are trying to edit the row with ID: ' + id;
23+
function edit(person) {
24+
vm.message = 'You are trying to edit the row: ' + JSON.stringify(person);
2425
// Edit some data and call server to make changes...
2526
// Then reload the data so that DT is refreshed
2627
vm.dtInstance.reloadData();
2728
}
28-
function deleteRow(id) {
29-
vm.message = 'You are trying to remove the row with ID: ' + id;
29+
function deleteRow(person) {
30+
vm.message = 'You are trying to remove the row: ' + JSON.stringify(person);
3031
// Delete some data and call server to make changes...
3132
// Then reload the data so that DT is refreshed
3233
vm.dtInstance.reloadData();
@@ -36,10 +37,11 @@ function BindAngularDirectiveCtrl($scope, $compile, DTOptionsBuilder, DTColumnBu
3637
$compile(angular.element(row).contents())($scope);
3738
}
3839
function actionsHtml(data, type, full, meta) {
39-
return '<button class="btn btn-warning" ng-click="showCase.edit(' + data.id + ')">' +
40+
vm.persons[data.id] = data;
41+
return '<button class="btn btn-warning" ng-click="showCase.edit(showCase.persons[' + data.id + '])">' +
4042
' <i class="fa fa-edit"></i>' +
4143
'</button>&nbsp;' +
42-
'<button class="btn btn-danger" ng-click="showCase.delete(' + data.id + ')">' +
44+
'<button class="btn btn-danger" ng-click="showCase.delete(showCase.persons[' + data.id + '])")">' +
4345
' <i class="fa fa-trash-o"></i>' +
4446
'</button>';
4547
}

0 commit comments

Comments
 (0)