angular JS中使用jquery datatable添加checkbox点击事件
'use strict'; app.controller('DataTableCtrl', function ($scope, $compile) { $scope.selected = []; $scope.isSelected = function (obj,index, id) { var checkbox = obj.target; checkbox.checked ? $scope.selected.push(id) : $scope.selected.splice(index,1); console.log($scope.selected); } $scope.simpleTableOptions = { sAjaxSource: '/Home/Index', "sServerMethod": "POST", "bProcessing": true, "bServerSide": true, "bPaginate": true, aoColumns: [ { data: 'id', 'bSortable': false, "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) { $(nTd).html('<input type="checkbox" ng-click="isSelected($event,' + iRow + ',' + oData.id + ')">'); $compile(nTd)($scope); }}, { data: 'id' }, { data: 'title' }, { data: 'add_time' } ], "sDom": "Tflt<'row DTTTFooter'<'col-sm-6'i><'col-sm-6'p>>", "iDisplayLength": 10, "oTableTools": { "aButtons": [ "copy", "csv", "xls", "pdf", "print" ], "sSwfPath": "assets/swf/copy_csv_xls_pdf.swf" }, "language": { "search": "", "sLengthMenu": "_MENU_", "oPaginate": { "sPrevious": "上一页", "sNext": "下一页" } }, "aaSorting": [], }; });