简体   繁体   中英

Adding style to ng-option on condition with AngularJs

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM