I have a dynamically generated table using ngFor in angular2 and I want to colour even rows differently from odd rows.
<div *ngIf="AreThereMyOldMessages">
<div *ngFor="let oldm of MyOldMessages;let i of MyOldMessages.length">
<tr>
<td>{{i}}<br>
{{oldm.text}}
</td>
</tr>
</div>
</div>
<div *ngIf="AreThereMyNewMessages">
<div *ngFor="let message of MyNewMessages;let i of MyNewMessages.length">
<tr>
<td>{{i}}<br>
{{message.text}}
</td>
</tr>
</div>
</div>
</table>
I want to colour each rows alternatively but this code prints all the rows in same colour. I have set a CSS file which colours each row accordingly using
table tr:nth-child(odd) td
this code.