Charlie Charlie - 6 months ago 21
Javascript Question

Changing disable flag in ng-options causes select to be unlselected

Example of the problem:

When that is loaded,

is selected even though its disabled. This is fine and expected.

Next, if you selected a non-disabled value, let's say
. That works.

But once you click the button to flip the
boolean, the model gets set to
and the select loses what's selected.

You can even flip the boolean for the initially selected value to not be disabled and the value stays, but then flip it again and it gets lost.

Is this expected? It doesn't seem that this should happen to me since the first use case allows it to be selected.

Answer Source

I posted the same question in the Angular github issue tracker and found out this behavior is by design. For me, that was good enough and we'll come up with another way to do it.

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