-
Notifications
You must be signed in to change notification settings - Fork 27.4k
SELECTs ng-model values not being bound for non-strings #13955
Comments
Hi, this issue has been documented pretty extensively and is marked as a breaking change: https://code.angularjs.org/snapshot/docs/guide/migration#select with suggested workarounds. The change was necessary, because otherwise |
But if you stringify the left-hand side of the comparison, you'd get And it's odd to have inconsistent handling of SELECTs from INPUT[type=radio] and INPUT[type=checkbox], or are these now similarly broken? There is no |
The only potentional issue would be |
It would get stringified if somebody tried to interpolate an object. If we are allowing numbers, boolean etc. by being clever with the comparison, there will be definitely be someone who tries the same with an object or an array, and that will fail. Simply put, interpolation produces strings, and attributes can only hold strings, so any way we are trying to be clever will break this contract and leat to broken edge cases. I have an idea how to use ngValue for binding arbitrary values to a select: #13962 But even this suffers from the problem that we have to work around the restriction for string values. |
Another potential issue is when someone does not want to have a See a demo of this here. |
I'm gonna close this, as there is currently nothing we can do about this / this works as expected. |
We have an issue with new
===
ng-options
/select
'sng-model
s value comparisons. A change with 1.4+ was to always have:be
=== "2"
as all underlyingvalue
s are strings (fair enough, but isn't this true of all HTML values?) rather than== 2
as per <1.4. The problem is none of our non-string boundselect
s are binding anymore because2 !== "2"
.From
==
to===
is a good change, but it seems the Angular team hasn't bothered to coerce the left-hand side of the expression into a string but has left that on us as devs to do it?! Really? So I have to change _ALL_ of my APIs rather than the Angular team addingvalue + ''
on the left?I'm working on a major Australian government system that uses Angular and we are unable to upgrade past 1.3 currently because of this problem. Or have we managed to miss an easy fix for this issue?
Here's an extremely simplified example of the issue we're experiencing:
Angular 1.3 binds the select without issue, while 1.4+ does
2 === "2"
et'al and of course doesn't find a match and leaves the select as blank.Our experience with replacing the HTML
option
s withng-options
has not fixed the issue (nor would it be appropriate in our case to deploy system wide). This is likely due to having both aselect
andtrack by
in theng-options
expression (which are gawd awful, by the way) which we have only recently found are non-compatible.Is the Angular team really saying that from 1.4+ we are no longer able to bind to a static
option
s list if our underlying value is non-string? Are these changes likely to be rolled out to<input type="radio"/>
s and<input type="checkbox"/>
s as well?The text was updated successfully, but these errors were encountered: