绑定的AngularJS模板不会更改角度数据

时间:2017-07-17 10:59:19

标签: angularjs angular-datatables

我正在使用下面链接中的角度数据表

http://l-lin.github.io/angular-datatables/archives/#!/bindAngularDirective

我在这里使用延迟撕裂概念。

我有2个按钮

  1. 有效(用户状态为1时显示)
  2. 无效(用户状态为0时显示)
  3. 由于2路数据绑定在这里不起作用。单击活动&后,我无法显示非活动按钮反之亦然

    以下是我的代码

     $scope.setCustomers = function (s, dto, dtc, f, c, h, t) {
        s.dtInstance = {};
        s.actions = {};
        //dtOptions - Makes the ajax request to get the customer records, also builds the buttons to copy,csv,excel..etc
        s.dtOptions = dto.fromSource('customers/showCustomers.json')
                .withPaginationType('full_numbers')
                .withDisplayLength(25)
                .withOption('createdRow', createdRow)
                .withDOM('<"html5buttons"B>lTfgitp').withDisplayLength(25);
    
        // dtColumns - Builds the columns and renders the rows for each column
        s.dtColumns = [
            dtc.newColumn('name').withTitle('Name'),
            dtc.newColumn('email').withTitle('Email'),
            dtc.newColumn('phone').withTitle('Phone'),
            dtc.newColumn('status').withTitle('Status')
                    .renderWith(function (data) {
                        return  "<div style=text-align:center;>" + (data == 1 ? 'Accepted' : data == 2 ? 'Declined' : 'Pending') + "</div>";
                    }),
            dtc.newColumn(null).withTitle('Actions').notSortable()
                    .renderWith(actionsHtml)
        ];
        function createdRow(row, data, dataIndex) {
            c(angular.element(row).contents())(s);
        }
        function actionsHtml(data, type, full, meta) {
            s.actions[data.id] = data;
            var actions = '<button ladda="loadingDemo' + data.customer_id + '" class="ladda-button ladda-button-demo btn btn-primary btn-xs" data-style="zoom-in" ng-click="resetPassword(actions[' + data.id + '])" uib-tooltip="Reset Password" tooltip-placement="top"><i class="fa fa-key"></i></button>&nbsp;'
                    + '<a href="#/customers/viewBalance/' + data.unique_id + "/" + data.customer_id + '" ><button class="btn btn-info btn-xs" uib-tooltip="Transaction History" tooltip-placement="top"><i class="fa fa-money"></i></button></a>&nbsp;'
                    + '<a href="#/invoices/view-invoice/' + data.unique_id + '" ><button class="btn btn-info btn-xs" uib-tooltip="View Orders"><i class="fa fa-files-o"></i></button></a>&nbsp;'
                    + '<a href="#/customers/view-customer/' + data.uniq_id + '" ><button type="button" class="btn btn-primary btn-xs" tooltip-placement="top" uib-tooltip="View Profile"><i class="fa fa-eye"></i></button></a>&nbsp;'
                    + '<a href="#/customers/add-customer/step-one/' + data.uniq_id + '" ><button class="btn btn-success btn-xs" tooltip-placement="top" uib-tooltip="Edit"><i class="fa fa-pencil"></i></button></a>&nbsp;';
            if (data.is_active == 1) {
                actions += '<button class="btn btn-success btn-xs" data-is_active="' + data.is_active + '" ng-click="setStatus(actions[' + data.id + '])" tooltip-placement="top" uib-tooltip="Inactive"><i class="fa fa-thumbs-up"></i></button>&nbsp;';
            } else {
                actions += '<button class="btn btn-danger btn-xs"  data-is_active="' + data.is_active + '" ng-click="setStatus(actions[' + data.id + '])" tooltip-placement="top" uib-tooltip="Active"><i class="fa fa-thumbs-down"></i></button>&nbsp;';
            }
    
            return actions;
        }
    }
    $scope.setCustomers($scope, DTOptionsBuilder, DTColumnBuilder, $filter, $compile, $http, toaster);
    

    由于

0 个答案:

没有答案