fix(select, ngOptions): make the handling of unknown / empty options consistent
- when the model does not match any option, the select generates an unknown option with the value '? hashedModelVal ?' (select) or simply '?' (ngOptions) and inserts it into the select. This option is then auto-selected by the browser. Once the user selects an option / the application sets a matching model, the unknown option is removed from the select. It is therefore not user-selectable. Alternatively, the application can provide an option with the value='', the so-called empty option. The empty option takes over the role of the unknown option, in that it is selected when there's no matching model, but it is not removed when a option and model match, and it can also be selected by the user. The empty option has the value='' and sets the model to if selected. Previously, these concepts where a bit mushy, especially in ngOptions. This fix now delegates the bulk of the work to the selectCtrl, as the concept of unknown and empty option are the same for both directives. Only the generation of the empty option is different. The commit also adjusts a test for an officially unsupported use-case: multiple empty options. The new behavior is that the empty option that is registered last is used. The other one is still present. Otherwise, this behavior is unspecified, and the docs are clear that only a single empty option is allowed. We support dynamically generated empty options, but not multiple ones. I've left the test to highlight that this might be someone's use case, and the we are aware of it.
M
Martin Staffa committed
2785ad72599ca5f9558a116baecd83a5bebe3292
Parent: ad9a99d