Applying ngClassEven and ngClassOdd like behavior to ngOptions

61 views Asked by At

I want to add Styling to ngOptions via ngClassEven and ngClassOdd. I know they are supposed to work with ngRepeat but in the mean time i could not switch to ngRepeat. I have seen this answer but it does not corresponds to my needs.

Is it possible to apply a behavior like ngClassEven and ngClassOdd for ngOptions?

Thanks in advance.

1

There are 1 answers

2
Freezystem On BEST ANSWER

you can do it in plain css

you html

<select class="sel" ng-options="item in items" ng-model="selected">

your css

.sel option:nth-child(even) {background: #ccc}
.sel option:nth-child(odd)  {background: #fff}