AngularJS- ng-selected
richtlijn
Voorbeeld
Stel het selected
attribuut in op true :
Click here to select BMW as your favorite car:
<input type="checkbox" ng-model="mySel">
<p>My Favourite car:</p>
<select>
<option>Volvo</option>
<option ng-selected="mySel">BMW</option>
<option>Ford</option>
</select>
Definitie en gebruik
De ng-selected
richtlijn stelt het geselecteerde attribuut van een <option>-element in een <select>-lijst in.
De optie wordt geselecteerd als de expressie binnen het ng-selected
attribuut waar retourneert.
De ng-selected
richtlijn is nodig om de waarde tussen true
en te kunnen verschuiven false
. In HTML kunt u het selected
attribuut niet instellen op false
(de aanwezigheid van het geselecteerde attribuut maakt het element geselecteerd, ongeacht de waarde ervan).
Syntaxis
<option ng-selected="expression"></option>
Ondersteund door het <option>-element.
Parameterwaarden
Value | Description |
---|---|
expression | An expression that will set the element's selected attribute if it returns true. |