-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Confusing Type Coercion with ng-value #15283
Comments
To determine the checkedness, the $viewValue and the ngValue are compared. In 1.5.8 this comparison is not strict. This has been fixed in master and the upcoming 1.5.9. In 1.5.9, this might actually be a breaking change, but going forward this is the right thing to do,
What do you mean by that? |
Gotcha! thanks. As far as a "blank" value goes, say you have two radio buttons, one with |
Closes angular#15283 BREAKING CHANGE: When using input[radio], the checked status is now determined by doing a strict comparison between the value of the input and the ngModel.$viewValue. Previously, this was a non-strict comparison (==). This means in the following examples the radio is no longer checked: ``` <!-- this.selected = 0 --> <input type="radio" ng-model="$ctrl.selected" value="0" > <!-- this.selected = 0; this.value = false; --> <input type="radio" ng-model="$ctrl.selected" ng-value="$ctrl.value" > ``` The migration strategy is to convert values that matched with non-strict conversion so that they will match with strict conversion.
That's right. |
Closes #15283 Closes #15288 BREAKING CHANGE: When using input[radio], the checked status is now determined by doing a strict comparison between the value of the input and the ngModel.$viewValue. Previously, this was a non-strict comparison (==). This means in the following examples the radio is no longer checked: ``` <!-- this.selected = 0 --> <input type="radio" ng-model="$ctrl.selected" value="0" > <!-- this.selected = 0; this.value = false; --> <input type="radio" ng-model="$ctrl.selected" ng-value="$ctrl.value" > ``` The migration strategy is to convert values that matched with non-strict conversion so that they will match with strict conversion.
This did make it into 1.6.0-rc.1 after all. Yay! |
Closes angular#15283 Closes angular#15288 BREAKING CHANGE: When using input[radio], the checked status is now determined by doing a strict comparison between the value of the input and the ngModel.$viewValue. Previously, this was a non-strict comparison (==). This means in the following examples the radio is no longer checked: ``` <!-- this.selected = 0 --> <input type="radio" ng-model="$ctrl.selected" value="0" > <!-- this.selected = 0; this.value = false; --> <input type="radio" ng-model="$ctrl.selected" ng-value="$ctrl.value" > ``` The migration strategy is to convert values that matched with non-strict conversion so that they will match with strict conversion.
What is the current behavior?
When a model value is
null
orundefined
, a radio button<input>
withng-value="false"
won't be shown as checked.When the model value is
""
or0
, a radio button<input>
withng-value="false"
will be shown as checked.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
http://plnkr.co/edit/oY0YipxdTJtjjZDDCDDu?p=preview
What is the expected behavior?
I understand the intent here (need for a "blank" value), but if type coercion is going to happen, shouldn't we either go all in, or not do it at all? This "halfway" type coercion is confusing. There should be some sort of option for
ng-value
that lets you turn on/off strict type coercion.The text was updated successfully, but these errors were encountered: