1

I am using the following code to render a select where the options are rendered with ng-options:

 <select ng-options="cat.id as cat.name for cat in categories">
       <option  value="" selected="selected">Default Option...</option>
 </select>

and I need to add a CSS style option (namely font-weight:bold) only to options that have paricular ids. Any suggestion?

gcswoosh
  • 1,279
  • 1
  • 15
  • 31

1 Answers1

0

If you need to style your options, consider using

<option
    ng-repeat="cat in categories"
    ng-value="{{ cat.id }}"
    ng-bind="cat.name"
    ng-style="cat.style"></option>
Mouradif
  • 2,666
  • 1
  • 20
  • 37
  • Thanks but unfortunately I need to use the ng-options directive – gcswoosh Jan 23 '17 at 15:15
  • 1
    Then you need to create a directive. Check this SO thread : http://stackoverflow.com/questions/15264051/how-to-use-ng-class-in-select-with-ng-options – Mouradif Jan 23 '17 at 15:16