ng-repeatを使用して値が入力されたテーブルがあります。私はテーブルの色を緑色と黄色で交互に色付けする必要があります。私はng-repeatなしで次のように試してみました。ng-repeatを使用したhtmlテーブルの代替行の色付け
.table-striped>tbody>tr:nth-of-type(odd)
{
background: yellow !important;
}
.table-striped>tbody>tr:nth-of-type(even)
{
background: green !important;
}
<html>
<div><table class="table table-striped">
<thead style="border: 1px solid">
<tr>
<th>Heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{value.val1}}</td>
</tr>
<tr>
<td>{{value.val2}}</td>
</tr>
<tr>
<td>{{value.val3}}</td>
</tr>
</tbody>
</table>
</div>
<html>
しかし、次のようにNGリピートを使用しながら、それが動作しない(すべての行が黄色そのものです)。助けてください。あらかじめありがとうございます。
.table-striped>tbody>tr:nth-of-type(odd)
{
background: yellow !important;
}
.table-striped>tbody>tr:nth-of-type(even)
{
background: green !important;
}
<html>
<div><table class="table table-striped">
<thead style="border: 1px solid">
<tr>
<th>Heading</th>
</tr>
</thead>
<tbody ng-repeat="value in values">
<tr>
<td>{{value.val1}}</td>
</tr>
</tbody>
</table>
</div>
<html>
与えるNG-クラストライ。期待どおりに動作するはずです。私はangleが最初のレンダリング後に値を作成するだけだと思うので、cssはスタイルを適用しません。 – codemax
私は両方見事に見えることができます。 – Chetan