简体   繁体   English

angular js数据表ng-click不起作用

[英]angular js data table ng-click not working

I am using Angular js data table.我正在使用 Angular js 数据表。 currently I need to pass row ID.目前我需要传递行 ID。 Therefore I am trying to call ng-click function.因此我试图调用 ng-click function。 but its not working.但它不工作。 Please check the below code请检查以下代码

$scope.dtOptions = DTOptionsBuilder.newOptions()
        .withOption('ajax', {
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            url: appConfig.apiUrl + "/approvalList?reqTraceId=" + $scope.requestApprovalId,
            xhrFields: { withCredentials: true },
            type: 'POST',
            data: function (d) {
                return JSON.stringify(d);

            },
            error: function (response) {
                ajaxErrorHandler.handle(response);
            }
        })

        .withDataProp('data')
        .withOption('processing', true)
        .withOption('serverSide', true)
        .withOption('scrollY', '400px')
        .withOption('scrollX', '100%')
        .withOption('scrollCollapse', true)

        .withOption('drawCallback', function (settings) {

        });

    $scope.dtColumns = [
        DTColumnBuilder.newColumn('traceId').withTitle('Trace ID').withClass('cus-id'),
        DTColumnBuilder.newColumn('approval.0.usr').withTitle('Name').withClass('cus-id'),
        DTColumnBuilder.newColumn('approval.0.threshold').withTitle('Match Strength %').withClass('cus-id'),
        DTColumnBuilder.newColumn('traceId').withTitle('Action').renderWith(function (data, type, full) {
            return '<div class="btn-group-xs">' +
                '  <button type="button" class="btn btn-flat btn-xs btn-success" ng-click="passId();">' +
                '    <i class="ion ion-eye"></i>' +
                '  </button>' +
                '</div>';
        }).withClass('text-center').notSortable()
    ];

I am using below function for testing purpose.我在下面使用 function 进行测试。 But Function did not call.但是 Function 没有调用。

 $scope.passId= function () {
        alert("hi")
    };

how i call function using this code.我如何使用此代码调用 function。 thanks谢谢

the function passId should be inside same controller then only it will works please check that. function passId 应该在同一个 controller 内,那么只有它才能工作,请检查。

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

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