-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngOption model value 0 or false treated as 'not selected' after 1.3.0-rc.4 #9639
Comments
@Narretz are you working on this? I see that @petebacondarwin recently assigned it to you. |
@jeffbcross I just got the assignment in the 1.x meeting, currently looking at the commit that might have caused it. It's one of those three: ab354cf, aad6095, 30996f8 I'll have a look tomorrow, but you might be able to point me in the right direction since you worked on the code. |
It wouldn't be ab354cf since that landed in 1.3.1 (after this issue appeared). Top of my head, I'm not sure which of the other two is more likely to have introduced it. |
@Narretz - any update on this one? |
No time yet unfortunately. I'll have another look on it later today, but if anyone else wants to take that's also okay. ----- Ursprüngliche Nachricht ----- @Narretz - any update on this one? |
Fix is here: #9949 |
Still the bug exist in latest version(v1.3.15) |
@mouryaamit would it be possible for you to create a plunker that shows the error? |
Was not able to find this bug mentioned after a search.
Specific Bug Behavior
Beginning with 1.3.0-rc.5, and continuing into today's snapshot, when one of the values in an ngModel choice set is the integer 0 or the boolean false, Angular now assumes this value is equivalent to having made no selection.
This is not a 'falsy' evaluation issue. The bug manifestation does not correspond to falsy values:
-1
- truthy, no bug0
- falsy, bug1
- truthy, no bugNaN
- falsy, no bugtrue
- truthy, no bugfalse
- falsy, bugundefined
- falsy, no bugnull
- falsy, no bug"1"
- truthy, no bug""
- falsy, no bug (select correctly chooses the new option with empty string value)Examples
The code in the following two Plunkrs is identical, except for the Angular version.
Correct behavior - Model value of empty string is reflected in the 'choose' option being visually selected at load time.
Angular 1.3.0-rc.4
http://plnkr.co/edit/OUfDk8mAneJ4pO3pwxbC?p=preview
Incorrect behavior - Model value of empty string is still stored as empty string, but the select tag visually shows the 'Zero' option being selected at load time, representing a state inconsistency between the visual display and the underlying data. Furthermore, the 'Zero' option cannot be selected directly at this point, since the tag already thinks it is selected. The user must select some other option first before returning the real selection to the 'Zero' option.
Angular 1.3.0-rc.5:
http://plnkr.co/edit/RfsAKybKJIqic4B9yBVr?p=preview
Demonstrated Need
Server-side returns list of choices in a format like so:
This format was chosen because it
Manifestation Code
The text was updated successfully, but these errors were encountered: