0
我使用datatable angularjs顯示用戶列表。我想隱藏顯示列使用有條件。假設角色是onther然後最後一列是不顯示和角色是管理員然後顯示這最後column.how可以做到這一點,我不知道任何人知道如何解決它請讓我知道。如果有條件地在數據表AngularJS中動態地隱藏/顯示列?
這是我controller.js:
app.controller("userscontroller", [
"$scope",
"$http",
"DTOptionsBuilder",
"DTColumnBuilder",
"userservice",
"$compile",
function ($scope, $http, DTOptionsBuilder, DTColumnBuilder, userservic, $compile) {
$scope.dtColumns = [
DTColumnBuilder.newColumn("fullName", "Full Name").withOption('name','firstname'),
DTColumnBuilder.newColumn("username", "Name").withOption('name','username'),
DTColumnBuilder.newColumn("email", "Email").withOption('name', 'email'),
DTColumnBuilder.newColumn(null).withTitle('Action').notSortable().renderWith(function (data, type, full, meta) {
return '<button class="btn btn-primary" ng-click="delete(' + data.id + ');"><i class="fa fa-eye"></i>' + '</button>';
})
]
$scope.dtOptions = userservice.GetAllUser(DTOptionsBuilder)
.withOption('processing', true)
.withOption('serverSide', true)
.withPaginationType('full_numbers')
.withDisplayLength(50)
.withOption('aaSorting', [3, 'desc'])
function createdRow(row, data, dataIndex) {
$compile(angular.element(row).contents())($scope);
}
}
]);
在這裏,我想如果(IsAdmin)然後顯示刪除列其他明智隱藏此欄該怎麼辦?
@ julien TASSIN有關這個如何解決它的任何想法? – coderwill
Admin從哪裏來?你如何佈置它? –
isAdmin來自