我正在使用下面链接中的角度数据表
http://l-lin.github.io/angular-datatables/archives/#!/bindAngularDirective
我在这里使用延迟撕裂概念。
我有2个按钮
由于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> '
+ '<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> '
+ '<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> '
+ '<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> '
+ '<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> ';
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> ';
} 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> ';
}
return actions;
}
}
$scope.setCustomers($scope, DTOptionsBuilder, DTColumnBuilder, $filter, $compile, $http, toaster);
由于