--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
Pete,
This is no small problem. I have provided ngOptions with both object and array data sets containing properties mapped to the options' value attribute where the value was an empty string without any luck. An empty string as a JavaScript property key is perfectly valid. Currently, if you provide a view model with a empty string going into the option value, when it is selected, AngularJS creates an option with the value of "?" with no/empty text AND changes the selection to it (making selecting the custom empty option IMPOSSIBLE). THEN, when the user selects an option with a non-empty value, the "?" option disappears. I suspect jQuery's .val() function has a role in assigning undefined when an empty string is passed, but that's no excuse.
You say developers can either put the "empty" option in the view or have business logic that defaults to some (non-"empty") option--those two workarounds provide completely disjoint use cases. Browser validation assumes required inputs (input, select, etc.) are invalid if the value is "falsey". The automatic "empty" option does not facilitate validation nor does it allow customization. Many developers want to put the "empty" option in business logic/ngOptions, period. Please consider looking through the code to find where you can respect the empty string as a valid value and most likely setting the select's ngModel to null when any of them are selected.
Regards,
Mark M. Young