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

would be nice for <select> to support ng-size or size="{{expression}}" so we can set the size to the actual size for dynamic multiple selects #1619

Closed

Description

@jstrachan

I've tried 1.0.2 and it seems any expression of the form <select size="{{something}}" which just gets set to size="0". I ended up having to hack around this with jquery which made me feel dirty ;) so wondered if there was a way of just allowing a size expression to be specified (or even defaulting it as the ng-options knows the size).

e.g. something like this...

      <select id="attributes" ng-size="whatnot.length" multiple ng-multiple="true" ng-model="selectedThings" ng-options="foo for foo in whatnot"></select>

Activity

  1. hotienvu commented on Mar 7, 2013

    @hotienvu

    I'm having the same problem. My workaround is to write a custom ngSize directive that 2way-binds to something and update the select.size attribute.
    https://gist.github.com/hotienvu/5105501

  2. mlegenhausen commented on Jun 7, 2013

    @mlegenhausen

    +1

  3. btford commented on Aug 24, 2013

    @btford
    Contributor

    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!

  4. yorch commented on Aug 28, 2013

    @yorch

    Same problem here using Angular 1.1.5

  5. reopened this on Aug 28, 2013
  6. RavenHursT commented on Nov 26, 2013

    @RavenHursT

    This bug is still present in 1.2

    This is clearly a bug since whatever angular is doing, it's overriding DEFAULT HTML functionality. {{ someValue }} works in other attributes, why not here? Looks to me like there's a default of "0" hardcoded in AngularJs somewhere. Having to write custom directives for setting a size attribute on a native HTML element is pretty ridiculous. I can't believe this had to be "reopened"... I mean.. this is pretty basic..

    http://www.w3schools.com/tags/att_select_size.asp

  7. btford commented on Nov 26, 2013

    @btford
    Contributor

    this is pretty basic..

    @RavenHursT, would you like to submit a pull request for this feature then?

  8. joshkurz commented on Nov 27, 2013

    @joshkurz
    Contributor

    so its strange that this works for input, but not select. The docs say that size can only be a non-negative integer http://www.w3.org/TR/html5/forms.html#attr-input-size. I know for a fact that when angular is parsing the attrs in collectDirectives the value of the select size attribute is already 0. This means that we cannot interpolate the value correctly, because we have lost the reference to the original string passed in from the view. Since the directives are collected before the compile functions are even ran, I would think the best solution is to create another directive that we know will not be defaulted by w3 standards.

  9. joshkurz commented on Nov 27, 2013

    @joshkurz
    Contributor
  10. RavenHursT commented on Dec 6, 2013

    @RavenHursT

    "If you're not willing to fix it yourself, then you're not allowed to point out that closing an issue when it's a clear bug is not exactly the best way to support a community project" is a pretty lame cop-out.

    If you're willing to take the time to go through and "clean out" old issues based solely on the frequency of their activity, then you'd think you may be willing to take the time to actually look into the problem when it's been a verifiable bug for over a year now...

  11. caitp commented on Dec 6, 2013

    @caitp
    Contributor

    Have y'all tried data-ng-attr-size="{{some interpolated expression}}" (since ~1.5, or cf17c6a at least) ? (edit I had previously written data-ng-size, which was a typo, oops!)

    example: http://plnkr.co/edit/a1xLPGn2YeW0WavH2auD?p=preview

    Considering you have this feature, can we close this as resolved by cf17c6a ?

  12. mlegenhausen commented on Dec 9, 2013

    @mlegenhausen

    I think there need be better documentation for ng-attr. It should be listed with the other directives and not only a little note in the Directives documentation.

  13. sidecut commented on Feb 17, 2014

    @sidecut

    @caitp -- brilliant! Thanks!

    However, @mlegenhausen is quite right. This is practically undocumented. One would expect it to be documented in the Directives section along with ngApp, ngBind, et al. (If it's not technically a directive, then by all means it should have its own section in the Developers Guide.)

  14. sidecut commented on Feb 20, 2014

    @sidecut

    @caitp is right in that this issue should probably be closed, but with the proviso that a new issue about better documentation be created. Currently this is documented in one place only: the section entitled "Creating Custom Directives." This is misleading as it implies that ngAttr is available only when creating directives. On the contrary, it's available anywhere in Angular. Example here: http://plnkr.co/edit/ompMeVYn0jjPttTqIonP?p=preview

  15. caitp commented on Feb 20, 2014

    @caitp
    Contributor

    Where does it say/imply that it's only available when creating directives?

  16. sidecut commented on Feb 20, 2014

    @sidecut

    It's implied because it only appears one section entitled "Creating Custom Directives." It's not using directives, but creating them, which is a natural dichotomy in software toolkits. Many users will skip that section, or will not think to look there when researching this topic. I used Angular quite productively for many months before I created a directive, so I would never think to read that section for a feature that is not limited to creating directives.

    Plus, more importantly to me, it does not show up on the API page at all, which I would consider an omission. The API page is used as something of a menu of all the ng-* bits that a developer expects to find in Angular. (Whether that's the intention of that page is another matter.) Thus it functions as a reference guide, and as such, if something doesn't appear there, it's effectively undocumented.

  17. caitp commented on Feb 20, 2014

    @caitp
    Contributor

    It's true that it's not the best name for the section, because the section is really an overview of what directives are, including how they can be created. A more appropriate place for the ngAttr* stuff might be in the compiler docs, but people never seem to look there.

  18. sidecut commented on Feb 20, 2014

    @sidecut

    I've dipped into the compiler docs, but I think most users would consider the compiler to be an advanced topic. Just the word "compiler" brings back memories of lexical analysis, parsers, and other topics from that one course you needed in order to complete the comp sci graduation requirements. ;-)

  19. ericsaupe commented on Apr 16, 2014

    @ericsaupe

    I agree with @sidecut, I wouldn't spend time looking into compiler docs unless I was really desperate for something. The solution from @caitp is the way to go as it is using current Angular directives without doubling up code with a new directive.

  20. jibwa commented on Jan 10, 2015

    @jibwa

    +1 @caitp data-ng-attr-size worked fine.

  21. JonahJ commented on Jun 17, 2016

    @JonahJ

    +1

  22. self-assigned this
    on Feb 15, 2017
  23. added a commit that references this issue on Feb 15, 2017
    2deaf28
  24. added a commit that references this issue on Mar 15, 2017
    548c6ae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions