You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
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
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>
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..
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.
"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...
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!)
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.
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.)
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.
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.
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. ;-)
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.
Activity
hotienvu commentedon Mar 7, 2013
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
mlegenhausen commentedon Jun 7, 2013
+1
btford commentedon Aug 24, 2013
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.8and1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.Thanks!
yorch commentedon Aug 28, 2013
Same problem here using Angular
1.1.5RavenHursT commentedon Nov 26, 2013
This bug is still present in
1.2This 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
btford commentedon Nov 26, 2013
@RavenHursT, would you like to submit a pull request for this feature then?
joshkurz commentedon Nov 27, 2013
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.
joshkurz commentedon Nov 27, 2013
Here is a proposed directive ngSize. It only works on SELECT tags as that is all it is needed for. http://jsfiddle.net/joshkurz/DFyWX/2/
RavenHursT commentedon Dec 6, 2013
"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...
caitp commentedon Dec 6, 2013
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 ?
mlegenhausen commentedon Dec 9, 2013
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.sidecut commentedon Feb 17, 2014
@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.)
sidecut commentedon Feb 20, 2014
@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
ngAttris available only when creating directives. On the contrary, it's available anywhere in Angular. Example here: http://plnkr.co/edit/ompMeVYn0jjPttTqIonP?p=previewcaitp commentedon Feb 20, 2014
Where does it say/imply that it's only available when creating directives?
sidecut commentedon Feb 20, 2014
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.
caitp commentedon Feb 20, 2014
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.
sidecut commentedon Feb 20, 2014
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. ;-)
ericsaupe commentedon Apr 16, 2014
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.
jibwa commentedon Jan 10, 2015
+1 @caitp data-ng-attr-size worked fine.
JonahJ commentedon Jun 17, 2016
+1
docs(select, ngOptions): add ngAttrSize as argument
docs(select, ngOptions): add ngAttrSize as argument