0

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.

Community
  • 1
  • 1
Master Mind
  • 3,014
  • 4
  • 32
  • 63

1 Answers1

1

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}
Freezystem
  • 4,494
  • 1
  • 32
  • 35
  • I have tested it in a plnkr but it seems not working . here is the plnkr http://plnkr.co/edit/h2wmXLxlUUJL6ha2Z4WB?p=preview . I'm using chrome on mac. – Master Mind Jun 11 '15 at 14:36
  • Actually it's due to the default styling of webkit browsers. You can't style this kind of element because these are intern directives of browsers. To override this behaviour you can try : `.sel {-webkit-appearance:none;appearance:none;}` or use custom directives like [Bootstrap dropdowns](http://getbootstrap.com/components/#dropdowns) or [AngularStrap Dropdowns](http://mgcrea.github.io/angular-strap/#/dropdowns) – Freezystem Jun 11 '15 at 14:44