Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngOptions group by does not display groups with value 0 #7015

Closed
rmehlinger opened this issue Apr 6, 2014 · 4 comments
Closed

ngOptions group by does not display groups with value 0 #7015

rmehlinger opened this issue Apr 6, 2014 · 4 comments

Comments

@rmehlinger
Copy link

When using the "group by" feature in ngOptions, if one of your groups has a value of 0, that group will not display in the dropdown. Rather its elements will appear not to be part of a group.

Plunker: http://plnkr.co/edit/ykKLmAHRj6mEO6XIeBRH?p=info

@lgalfaso
Copy link
Contributor

lgalfaso commented Apr 7, 2014

It looks like a real bug, but the fix will involve a small breaking change

@lgalfaso
Copy link
Contributor

lgalfaso commented Apr 7, 2014

As a size note using the string '0' should do what it is expected

lgalfaso added a commit to lgalfaso/angular.js that referenced this issue Apr 7, 2014
Accept `0` and an option group

Close angular#7015

BREAKING CHANGE

When using option groups at an ng-option, the literal `0` will
be handled as a group with label `'0'`. Use the literal string `''`
or undefined for options that should not be in any option group
@rmehlinger
Copy link
Author

Yeah, using 'toString()' should be a viable workaround most of the time. However my guess is this is using truthy evaluation, so I would suspect this would also break on blank strings, which are probably also a valid use case?

lgalfaso added a commit to lgalfaso/angular.js that referenced this issue Apr 7, 2014
Accept `0` and an option group

Close angular#7015

BREAKING CHANGE

When using option groups at an ng-option, the literal `0` will
be handled as a group with label `'0'`. Use the literal string `''`
or undefined for options that should not be in any option group
@lgalfaso
Copy link
Contributor

lgalfaso commented Apr 7, 2014

@rmehlinger I think that using 0 should work, but expecting that '' works would be calling it a stretch as a label for an option group with a value of '' makes little sense (unless I see a very good example where it does)

@lgalfaso lgalfaso removed their assignment May 13, 2014
@Narretz Narretz added this to the Backlog milestone Jul 2, 2014
@btford btford removed the gh: issue label Aug 20, 2014
@Narretz Narretz self-assigned this Jun 9, 2015
@Narretz Narretz modified the milestones: 1.5.x - migration-facilitation, Backlog Sep 14, 2015
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this issue Sep 18, 2015
Now one can use `''`, `0`, `false` and `null` as option groups. Previously
all of these falsy values were treated as the option not being a member of
a group.

Closes angular#7015
Closes angular#7024

BREAKING CHANGES
If your data contains falsy values for option groups, then these options
will now be placed into option groups. Only option groups that are `undefined`
will result in the option being put in no group. If you have data that
contains falsy values that should not be used as groups then you must
filter the values before passing them to `ngOptions` converting falsy
values to `undefined`.
@Narretz Narretz removed their assignment Sep 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants