Angular 角材质2 md列表奇偶样式

Angular 角材质2 md列表奇偶样式,angular,angular-material2,Angular,Angular Material2,我试图为md列表中的奇偶行设置不同的背景。 不确定使用Angular Material 2-Md列表组件是否支持此功能,因为我没有看到任何关于此功能的文档 我相信angular 2支持使用ng类奇数/ng类偶数,您应该在组件中使用以下样式 .mat-list > .mat-list-item:nth-child(2n+1){ background-color:red; } .mat-list > .mat-list-item:nth-child(2n){ backgrou

我试图为md列表中的奇偶行设置不同的背景。 不确定使用Angular Material 2-Md列表组件是否支持此功能,因为我没有看到任何关于此功能的文档


我相信angular 2支持使用ng类奇数/ng类偶数,您应该在组件中使用以下样式

.mat-list >  .mat-list-item:nth-child(2n+1){
  background-color:red;
}
.mat-list >  .mat-list-item:nth-child(2n){
  background-color:blue;
}

您应该在组件中使用以下样式

.mat-list >  .mat-list-item:nth-child(2n+1){
  background-color:red;
}
.mat-list >  .mat-list-item:nth-child(2n){
  background-color:blue;
}