我有以下代码。我可以传递一个二维数组,它将显示独立于数组大小的行
<div body-height class="flex-table_body horizontal-scroll flex-table_body--global-search" >
<div class="flex-table_row" ng-repeat="row in records">
<div class="flex-table_cell flex-table_col2" ng-repeat="item in row track by $index">
{{item}}
</div>
</div>
我现在想要不显示数组中的第一个字段,如果它是某个值,则对该行应用不同的样式
有什么想法吗?
答案 0 :(得分:0)
如果要根据第一行列值更改行样式,请执行以下操作:
在您看来:
<div body-height class="flex-table_body horizontal-scroll flex-table_body--global-search">
<div class="flex-table_row"
ng-repeat="row in records"
ng-class="{ 'yourClass': checkFirstCol(row) }">
<div class="flex-table_cell flex-table_col2"
ng-repeat="item in row track by $index">
{{item}}
</div>
</div>
</div>
在你的控制器中:
$scope.checkFirstCol = function(row) {
var firstColumn = row[0];
var wantedValue = 'Your Value';
if(undefined !== firstColumn && null !== firstColumn) {
return wantedValue == firstColumn;
}
return false;
};
答案 1 :(得分:0)
因为我总是新的,第一列将包含我需要的数据,我得到了以下标记
<div body-height class="flex-table_body horizontal-scroll flex-table_body--global-search">
<div class="flex-table_row" ng-class="{'danger': row[0] === 'error', 'warning': row[0] === 'warning'}" }" ng-repeat="row in records">
<div class="flex-table_cell flex-table_col2" ng-repeat="item in row track by $index"
ng-class="{ 'hideColumn': $index === 0 }">
{{item}}
</div>
</div>