5

I have a select box.

When no value is selected, I have the empty option --. It's OK !

Once an option is selected, the empty option disappears.

But I would like that it is always there to have the opportunity to choose --.

Is it possible ?

<select ng-model="project" ng-options="act.id as act.name for act in actors"></select>
1

2 Answers 2

9

please see here:http://plnkr.co/edit/SWpRZA1dafNNva70z6KE?p=preview

<select ng-model="project" ng-options="act.id as act.name for act in actors">
    <option value="">--<option>
  </select>
Sign up to request clarification or add additional context in comments.

3 Comments

Your code doesn't seem to store in the model item.color
That was just sample I've update plukr for you plnkr.co/edit/SWpRZA1dafNNva70z6KE?p=preview
Thank you ! Exactly what I want
0

ng-options gets priority when any option is selected from <select>.

As per the standard html <select> can contain <option>. Thus the mentioned option gets priority as the selection is null.

And in view, html priority is higher, thus always <option> value is seen unless the ng-option value already selected from controller.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.