angularjs - Roll back ngOptions select to unselected state -


ngopions creates blank option option html below if model value doesn't match of option values:

<option value="?" selected="selected"></option> 

after selection made, angularjs removes first empty option html select html.

i have use case want roll state of html select unselected option angularjs removed. tried ngmodel methods $setpristine(), $rollbackviewvalue(), , $setuntouched(). none of these mothods puts state of select initial state empty option.

is possible truely roll angularjs select element have empty option after selection made?

the code ngoptions (line 473 in ngoptions.js ) suggests single-select can it, , writevalue function (called when ngmodel changes) has invoked null value (not undefined, === used.)

so can try setting model variable null.

if doesn't work, expect may out of luck far proper solutions go, , might need re-render whole directive. can create pretty simple directive that, similar what's suggested in answer: https://stackoverflow.com/a/22133080/624590


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -