繁体   English   中英

Angular Datatable ng-click不起作用

[英]Angular Datatable ng-click not working

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')
    }

删除按钮不起作用。

代码有什么问题吗?

 $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')
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM