简体   繁体   中英

angular js data table ng-click not working

I am using Angular js data table. currently I need to pass row ID. Therefore I am trying to call 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. But Function did not call.

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

how i call function using this code. thanks

the function passId should be inside same controller then only it will works please check that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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