Οδηγός για την εντολή AngularJS ng-selected

ορισμός και χρήση

ng-selected η εντολή ρυθμίζει <select> στη λίστα <option> στο στοιχείο selected ιδιότητα

εάν ng-selected το εκφραστικό της ιδιότητας επιστρέφει trueή επιλέγεται αυτή η επιλογή.

ng-selected Η εντολή είναι απαραίτητη για τη μετατροπή τιμών μεταξύ true και false. Στο HTML, δεν μπορεί να ρυθμιστεί η ιδιότητα selected σε false (η ύπαρξη της ιδιότητας selected επιτρέπει την επιλογή του στοιχείου, ανεξάρτητα από την τιμή του).

Example

Set the selected attribute to true:

Please click here to select BMW as your favorite 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

Syntax

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

Affected <option> Element Support.

Parameters

Parameters Description
expression If it returns true, then the expression of the selected attribute of the element is set.