Skip to content

Commit 87da01f

Browse files
committed
Correct example on binding angular directive
1 parent 039ccfe commit 87da01f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

demo/advanced/bindAngularDirective.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ <h1><i class="fa fa-play"></i>&nbsp;Binding Angular directive to the DataTable</
3838
vm.edit = edit;
3939
vm.delete = deleteRow;
4040
vm.dtInstance = {};
41+
vm.persons = {};
4142
vm.dtOptions = DTOptionsBuilder.fromSource('data1.json')
4243
.withPaginationType('full_numbers')
4344
.withOption('createdRow', createdRow);
@@ -49,14 +50,14 @@ <h1><i class="fa fa-play"></i>&nbsp;Binding Angular directive to the DataTable</
4950
.renderWith(actionsHtml)
5051
];
5152

52-
function edit(id) {
53-
vm.message = 'You are trying to edit the row with ID: ' + id;
53+
function edit(person) {
54+
vm.message = 'You are trying to edit the row: ' + JSON.stringify(person);
5455
// Edit some data and call server to make changes...
5556
// Then reload the data so that DT is refreshed
5657
vm.dtInstance.reloadData();
5758
}
58-
function deleteRow(id) {
59-
vm.message = 'You are trying to remove the row with ID: ' + id;
59+
function deleteRow(person) {
60+
vm.message = 'You are trying to remove the row: ' + JSON.stringify(person);
6061
// Delete some data and call server to make changes...
6162
// Then reload the data so that DT is refreshed
6263
vm.dtInstance.reloadData();
@@ -66,10 +67,11 @@ <h1><i class="fa fa-play"></i>&nbsp;Binding Angular directive to the DataTable</
6667
$compile(angular.element(row).contents())($scope);
6768
}
6869
function actionsHtml(data, type, full, meta) {
69-
return '<button class="btn btn-warning" ng-click="showCase.edit(' + data.id + ')">' +
70+
vm.persons[data.id] = data;
71+
return '<button class="btn btn-warning" ng-click="showCase.edit(showCase.persons[' + data.id + '])">' +
7072
' <i class="fa fa-edit"></i>' +
7173
'</button>&nbsp;' +
72-
'<button class="btn btn-danger" ng-click="showCase.delete(' + data.id + ')">' +
74+
'<button class="btn btn-danger" ng-click="showCase.delete(showCase.persons[' + data.id + '])")">' +
7375
' <i class="fa fa-trash-o"></i>' +
7476
'</button>';
7577
}

demo/advanced/bindAngularDirective.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function BindAngularDirectiveCtrl($scope, $compile, DTOptionsBuilder, DTColumnBu
4141
return '<button class="btn btn-warning" ng-click="showCase.edit(showCase.persons[' + data.id + '])">' +
4242
' <i class="fa fa-edit"></i>' +
4343
'</button>&nbsp;' +
44-
'<button class="btn btn-danger" ng-click="showCase.delete(showCase.persons[' + data.id + '])")">' +
44+
'<button class="btn btn-danger" ng-click="showCase.delete(showCase.persons[' + data.id + '])">' +
4545
' <i class="fa fa-trash-o"></i>' +
4646
'</button>';
4747
}

0 commit comments

Comments
 (0)