角JS纳克级的奇嵌套NG-重复
我试图建立一个非常通用的表格输出器 - 行或列中没有定数。因此,我有嵌套的NG-重复属性,例如:
I'm trying to develop a very generic table outputter - no set number of rows or columns. As such, I've got nested ng-repeat attributes, as such:
<table>
<tr ng-repeat="row in rowList">
<td ng-repeat="col in colList">{{printCell(row,col)}}</td>
</tr>
</table>
它的工作太棒了!直到我尝试使用纳克级,甚至
和纳克级的奇
来改变行的背景颜色因此。
It's working great! Until I try to use ng-class-even
and ng-class-odd
to change the background color of the rows accordingly.
如果我把纳克级 - 对
标签,我得到交替柱颜色。 ***
语句TD
If I put the ng-class-***
statements on the td
tag, I get alternating column colors.
如果我把纳克级 - 对
声明,我不知道得到的任何的类任务 - 他们都留默认 TR
标记***
If I put the ng-class-***
statements on the tr
tag, I don't get any class assignment - they all stay default.
我要交替行颜色。我怎么会去这样做?
I want alternating row colors. How do I go about doing this?
编辑:
请删除此,有人?原来,问题是我的CSS类被指定的类分别设置在td标签。
Please delete this, someone? It turns out the problem was that my css classes were specifying that the class were set on a td tag.
的值纳克级的奇
和纳克级,甚至
可以是一个字符串:纳克级的奇='MyClass的'
或前pression 纳克级奇={MyClass的:boolEx pression}
The value of ng-class-odd
and ng-class-even
can be a string: ng-class-odd="'myClass'"
or an expression ng-class-odd="{myClass: boolExpression}"
还有:
角1.2+:纳克级={连:$偶,奇:$奇}
<table>
<tr ng-repeat="row in rowList" ng-class="{even: $even, odd: $odd}">
<td ng-repeat="col in colList">{{printCell(row,col)}}</td>
</tr>
</table>
<hr />
&角LT; 1.2 纳克级={连:($索引%2),奇($索引%2)}
<table>
<tr ng-repeat="row in rowList" ng-class="{even: !($index%2), odd: ($index%2)}">
<td ng-repeat="col in colList">{{printCell(row,col)}}</td>
</tr>
</table>