This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
select directive should allow user to handle missing option for given model value #10127
Milestone
Comments
I think this sounds reasonable. Fancy putting together a PR? |
I'll try to put something together. It's not trivial thou, so anyone feel free to contribute in any way. |
As I'm thinking about it, I realised that this code itself may not have correct behavior:
Using placeholder for unrecognized model value seems wrong to me. I think it would be nice to provide template option for invalid value as well, and keep placeholder option. With current behavior, when you have placeholder option specified, and unknown model value, it is presented as no value at all. It is also impossible to deselect the value. I think i'll create separate PR for this first. |
This seems to work, I need to perform a lot of tests + unit tests, but anyway, take a look... |
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Apr 26, 2017
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Apr 27, 2017
This allows custom directives to manipulate the select's and ngModel's behavior based on the state of the unknown and the empty option. Closes angular#13172 Closes angular#10127
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Apr 27, 2017
This allows custom directives to manipulate the select's and ngModel's behavior based on the state of the unknown and the empty option. Closes angular#13172 Closes angular#10127
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Apr 27, 2017
This allows custom directives to manipulate the select's and ngModel's behavior based on the state of the unknown and the empty option. Closes angular#13172 Closes angular#10127
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Angular 1.3.3, single-value select directive
Today, when model has value that is not in ng-options collection, it inserts either placeholder option or empty option with '?' value. There is however no way to validate this state, since its all stored in private variables and model is considered valid. It is impossible to mark such field visually using css.
Directive should set a flag on ngModel controller to allow validation. All logic is now however in its $render method, and I'm not sure its the right place to do that, althou it would probably work.
When this is done, it would be easy to add custom validator that would check this flag and mark the field as invalid. Such validation directive could be part of core, since its quite common use-case, that non-existent value in select is invalid value.
The text was updated successfully, but these errors were encountered: