我有一个动态创建的ngTable,设置每列的行颜色。如何更改列标题的颜色?如何以编程方式更改ngTable标题颜色?
HTML:
<table ng-table-dynamic="tableParams with cols" class="table table-bordered table-hover">
<tr ng-repeat="row in data">
<td ng-repeat="col in cols" ng-style="{ 'color': col.color }">{{row[col.nm]}}</td>
</tr>
</table>
的Javascript:
var app = angular.module('app', ['ngTable']);
app.controller('myCtl', function($scope,NgTableParams) {
$scope.cols = [
{nm:'uid', title:'User ID', color: 'blue'},
{nm:'ugr', title: 'Group ID', color: 'red'}
];
$scope.data = [
{ uid: 'aaa',ugr: '222'},
{ uid: 'bbb', ugr: '111'}
];
$scope.tableParams = new NgTableParams({dataset: $scope.data});
});
你的解决方案有效,是首选的解决方案,因为它可以让我以编程方式更改颜色无类。然而,它打破了每页的行数,看看这个plunk,表应该显示每行3行,而不是4. http://plnkr.co/edit/98kvWKgzE8fwgsEjkQce?p=preview – ps0604