在角度数据表上点击ng有问题。我正在使用https://l-lin.github.io/angular-datatables
这是我的代码
$scope.dtOptions = DTOptionsBuilder.fromFnPromise(function(){
return $resource(APIROOT + 'categories').query().$promise;
})
.withOption('order', [0, "asc"]);
$scope.dtColumns = [
DTColumnBuilder.newColumn('id', 'ID').withOption('searchable', false),
DTColumnBuilder.newColumn('name', 'Name'),
DTColumnBuilder.newColumn('', 'Actions').renderWith(function (data, type, full, meta) {
return '<a class="btn btn-default btn-xs" href="#/edit/' + full.id + '"><i class="fa fa-pencil"></i></a> ' +
'<button class="btn btn-danger btn-xs" ng-click="deleteItem(' + full.id + ')"><i class="fa fa-trash"></i></button>';
})
];
$scope.deleteItem = function (id) {
alert('delete')
}
删除按钮不起作用。
代码有什么问题吗?
答案 0 :(得分:2)
$scope.dtOptions = DTOptionsBuilder.fromFnPromise(function(){
return $resource(APIROOT + 'categories').query().$promise;
})
.withOption('createdRow', createdRow)
.withOption('order', [0, "asc"]);
function createdRow(row, data, dataIndex) {
// Recompiling so we can bind Angular directive to the DT
$compile(angular.element(row).contents())($scope);
console.log("test");
}
//now ur deleteItem function is complied and it'll work.
$scope.deleteItem = function (id) {
alert('delete')
}