@@ -38,6 +38,7 @@ <h1><i class="fa fa-play"></i> Binding Angular directive to the DataTable</
38
38
vm.edit = edit;
39
39
vm.delete = deleteRow;
40
40
vm.dtInstance = {};
41
+ vm.persons = {};
41
42
vm.dtOptions = DTOptionsBuilder.fromSource('data1.json')
42
43
.withPaginationType('full_numbers')
43
44
.withOption('createdRow', createdRow);
@@ -49,14 +50,14 @@ <h1><i class="fa fa-play"></i> Binding Angular directive to the DataTable</
49
50
.renderWith(actionsHtml)
50
51
];
51
52
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) ;
54
55
// Edit some data and call server to make changes...
55
56
// Then reload the data so that DT is refreshed
56
57
vm.dtInstance.reloadData();
57
58
}
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) ;
60
61
// Delete some data and call server to make changes...
61
62
// Then reload the data so that DT is refreshed
62
63
vm.dtInstance.reloadData();
@@ -66,10 +67,11 @@ <h1><i class="fa fa-play"></i> Binding Angular directive to the DataTable</
66
67
$compile(angular.element(row).contents())($scope);
67
68
}
68
69
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 + ']) "> ' +
70
72
' < i class ="fa fa-edit "> </ i > ' +
71
73
'</ button > ' +
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 + ']) " ) "> ' +
73
75
' < i class ="fa fa-trash-o "> </ i > ' +
74
76
'</ button > ';
75
77
}
0 commit comments