问题
Am trying to have a different background for odd/even rows in the md-list. Not sure if this is supported using Angular Material 2 - Md-list component as I don't see any documentation on this.
I believe angular 2 supports this using the ng-class-odd/ng-class-even
回答1:
You should be using below styles in your component
.mat-list > .mat-list-item:nth-child(2n+1){
background-color:red;
}
.mat-list > .mat-list-item:nth-child(2n){
background-color:blue;
}
LIVE DEMO
来源:https://stackoverflow.com/questions/42351202/angular-material-2-md-list-odd-even-style