`select` won't work when `required` attr is set and option's value is `false`
<select ng-model="bValue"
ng-options="o.value as o.text for o in options"
required></select>
$scope.options = [{value:true, text:"Yes"}, {value:false, text:"No"}];
When choose "No", bValue is not set to false.
- if remove
requiredattr, it work as normally. - the "Yes" option works normally.
$scope.options = [{value:1, text:"Yes"}, {value:0, text:"No"}];works normally.
Just ran into this as per implementation of required directive:
var validator = function(value) {
if (attr.required && (isEmpty(value) || value === false)) {
This seems a bit surprising for false to be interpreted as the absence of a model value. What was the rationale?
Answered my own question, I suppose. required treats false this way to work on checkboxes. Solution is to use a custom parser/formatter on the model and change view value to something not falsey (ie 0)
As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.
Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.
Thanks!
This is still an issue (using v1.1.5).
Still an issue 1.4
Even I am facing the same issue.