@@ -8,6 +8,7 @@ function BindAngularDirectiveCtrl($scope, $compile, DTOptionsBuilder, DTColumnBu
8
8
vm . edit = edit ;
9
9
vm . delete = deleteRow ;
10
10
vm . dtInstance = { } ;
11
+ vm . persons = { } ;
11
12
vm . dtOptions = DTOptionsBuilder . fromSource ( 'data1.json' )
12
13
. withPaginationType ( 'full_numbers' )
13
14
. withOption ( 'createdRow' , createdRow ) ;
@@ -19,14 +20,14 @@ function BindAngularDirectiveCtrl($scope, $compile, DTOptionsBuilder, DTColumnBu
19
20
. renderWith ( actionsHtml )
20
21
] ;
21
22
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 ) ;
24
25
// Edit some data and call server to make changes...
25
26
// Then reload the data so that DT is refreshed
26
27
vm . dtInstance . reloadData ( ) ;
27
28
}
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 ) ;
30
31
// Delete some data and call server to make changes...
31
32
// Then reload the data so that DT is refreshed
32
33
vm . dtInstance . reloadData ( ) ;
@@ -36,10 +37,11 @@ function BindAngularDirectiveCtrl($scope, $compile, DTOptionsBuilder, DTColumnBu
36
37
$compile ( angular . element ( row ) . contents ( ) ) ( $scope ) ;
37
38
}
38
39
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 + '])">' +
40
42
' <i class="fa fa-edit"></i>' +
41
43
'</button> ' +
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 + '])" )">' +
43
45
' <i class="fa fa-trash-o"></i>' +
44
46
'</button>' ;
45
47
}
0 commit comments