user3847750 user3847750 - 1 year ago 88
HTML Question

In Angular, how do you make the <option> text bold on selection?

For example:

My dropdown is having some options like:

  • India

  • America

  • England

By default top most option is "Choose your country".
My problem is, on selection- if I choose India. Select should show "India" in bold, if I go back and select "Choose your country" . Select should show "Choose your country" as text (not bold) does anyone have a suggestion?

Answer Source

You can do this using ng-class.

<div ng-controller="MyCtrl">
 <select ng-model="selectedVal" ng-class="{'bold':selectedVal!='Choose'}">
    <option value="Choose">Choose</option> 
    <option value="Grandvalira">Grandvalira</option> 
    <option value="Vallnord">--Vallnord</option> 


Working Demo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download