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


example of problem:

https://embed.plnkr.co/5msjb9e7amndf5ozqjrr/

when loaded, h selected though disabled. fine , expected.

next, if selected non-disabled value, let's d. works.

but once click button flip disable boolean, model gets set null , select loses what's selected.

you can flip boolean selected value not disabled , value stays, flip again , gets lost.

is expected? doesn't seem should happen me since first use case allows selected.

"but once click button flip disable boolean, model gets set null , select loses what's selected."

your selected variable evaluates null, because in filter have disable when option.disable. there no selected value after switching disable property true, , evaluates null. can fix selecting 1 option, click, example, or programmatically (i think better way).

i have added automatic selection of none-disabled option after disabling one, here working plunker:

https://plnkr.co/edit/hr7am1wxklgraem8qwit?p=preview

or if want display "select option" when nothing selected - here plunker:

https://plnkr.co/edit/vttb1u5qtbts3o8clqfg?p=preview


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -