WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-selected Directive


Example

Make the information field readonly:

Snap here to choose BMW as your most loved car:
<input type="checkbox" ng-model="mySel">

<p>My Favorite car:</p>

<select>
<option>Volvo</option>
<option ng-selected="mySel">BMW</option>
<option>Ford</option>
</select>
Try it yourself »

Definition and Usage

The ng-selected mandate sets the chose quality of an <option> component in a <select> list.

The choice will be chosen if the articulation inside the ng-selected trait returns true.

The ng-selected mandate is important to most likely move the esteem between true and false. In HTML, you can't set the selected ascribe to false (the nearness of the chosen property makes the component chose, paying little mind to it's value).


Syntax

<option ng-selected="expression"></option>

Supported by the <option> element.


Parameter Values

Value Description
expression An articulation that will set the component's chosen property on the off chance that it returns true.