我有一個動態創建的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