Angular Datatable ng-click不起作用 [英] Angular Datatable ng-click not working
本文介绍了Angular Datatable ng-click不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用ng键单击角度数据表时遇到问题。我正在使用 https://l-lin.github.io/angular-datatables
got a problem with ng-click on angular datatables. I'm using 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')
}
删除按钮不起作用。
代码有什么问题吗?
推荐答案
$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')
}
这篇关于Angular Datatable ng-click不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文