-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ng-enabled #1252
Comments
what is the rationalization? On Fri, Aug 10, 2012 at 7:01 AM, cric [email protected] wrote:
|
You need to use ng-disabled - there is no HTML attribute called enabled. |
It should be added for completeness... Why have both ng-show and ng-hide when you can just use ng-hide? It sometimes reads better, just like the show/hide variants, by avoiding double negatives: Vs: |
+1 |
+1 I have a function in this attribute. It confused the hell of me that I need to return true to disable the button. |
+1 |
1 similar comment
+1 |
as @adz said, like ng-show and ng-hide |
+1 as it makes for better readability - an ng-enabled would eliminate double negatives |
+1 👍 |
+1 as well. I spent a few minutes today wondering why my ng-enabled="blah" directive wasn't working before I realized that there wasn't one. |
👍 |
+1 Come on guys, you can make it |
+1 for intuitiveness, lower barrier to entry |
+1 double negatives are harder to think about and easier to screw up |
+1 if you have ng-hide and ng-show you should also have ng-enabled |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 =] |
+1 |
Being new to angular and having just read about ng-show and ng-hide, I sort-of expected there to be ng-enabled to pair with ng-disabled too 👍 |
+1 |
+1...this is a simple thing that makes a huge difference in code readability. |
+1 |
Come on AngularJS developers, it might take only a few secs to commit but now you are stalling us for a year? |
I have added it to a milestone after we get RC3 out the door, for discussion. Perhaps someone would like to make a tested, CLA-signed PR with decent commit messages? |
I think the whole precedence discussion about a possible but unlikely scenario of having the conflicting directives on the same element is a distraction. The real question is do we want this in Angular core or not. Either way we go, we should have a reason for it and I'm sorry but many +1 are not enough force the decision. Consistency and predictability are more important.
So what's up with If we wanted to make it consistent with the rest of the system, we'd have to created Q: What about So what if someone wants Now why on earth was this labeled as "PRs plz" is not clear to me. I think it was done by an accident by someone on the team and I apologize for that. I'm sorry to disappoint many people on this thread, but we need to keep Angular focused and consistent. If someone can be done via a non-core module then it should be done that way. Otherwise we'll end up with a bloated code base that contains random features that overall make no sense. |
I made a npm module/bower component here –> https://github.com/btford/angular-enabled |
@bford, you are the man! @IgorMinar, thank you for your thoughtful reply and the additional context that went into your decision. |
+5 |
"We can't add X, even though dozens are asking for it, because we wouldn't want to add Y and Z, which no-one is asking for." |
From the perspective of interface design, logic should be named using positive terms. As @graphnode says above it is confusing that the value true disables something. True (positive) should be associated with something positive (enabled). Some argue that ngDisabled is named such since it controls the disabled HTML attribute and therefore an ngEnabled makes no sense ... since there is no enabled HTML attribute. And that's a fair point. The question becomes: is ngDisabled a low level helper for the disabled attribute? Or is it a higher level feature -- the way to control whether something is enabled? I suggest that it should be the latter. First, adding abstraction to a system leads to better code. Second, as a programmer with limited HTML experience I would rather rely on a library such as NG than to learn about the details of HTML. I'd be happy if I never knew that HTML had a disabled attribute. FWIW I do not think that ngEnabled should be added for completeness -- since both ngHide and ngShow exist. Therefore, there is no need for something like ngUnchecked. Besides, that's negative. ngChecked is the right choice. |
👍 what @stevebroshar says! Abstract away from freaky lower level details. |
Symfony2 has a project tag DX, which stands for Developer Experience. The option to support ng-support would really qualify to improve the angularjs developer experience. |
I have to agree with @IgorMinar and @stevebroshar. I understand why Igor doesn't want to add it and his arguments are very valid, however I think steve broshar's counter is the correct way to go. Unless it's impossible to implement it this way and support IE. Negative logic statements are just bad, even if HTML surfaces it that way. |
@blakekl: I don't view it as negative logic or positive logic, but rather a way to deviate from the default. By default, form fields are enabled (interactive, usable, clickable, etc), and write-able; check boxes by default are un-checked; dropdown options are by default unselected (and default to the top row by UI convention). The HTML boolean attributes only serve to override the default behavior, and do not take any stance on positivity or negativity. There's nothing negative or positive about a read-only field, it's just read-only. You may decide that "enabled" is positive and "disabled" is negative, but that's only true in the context of your particular application. |
@jamesdaily +1 perfect! It is funny to see how much philosophy is hidden behind an ng-enabled attribute. It is also funny to see how customers (developers using angular for real applications) requesting an enhancement are dismissed basing the reasoning on not sustainable arguments. So for the sake of maintaining this comment page under 1GB in space you shall really listen to the requests and insert the new attribute. Or at least remove the ng-show one, as at that point would be unnecessary if not confusing. |
this is a perfect example of how developers can become arrogant stubborns. |
@mstdokumaci : Code of conduct |
@jamesdaily I use the terms 'positive' and 'negative' loosely, mostly based on my experience that using what I called 'negative' frequently results in code that reads with double negatives. Positive is simply the opposite. Sorry if the terminology was confusing. I didn't mean it to be. I frequently see form submit buttons with something like: ng-disabled="!isValid();" which seems to cause confusion on our team. |
@blakekl, I see your point, but then again you can simply do: |
+1 on having it baked in |
please put in ng-enabled |
+1024 |
My dear ng-enabled , I miss you so much ... |
An argument that ng-enabled should not exist because there's no such attribute as "enabled" is irrelevant when compared to the fact that there's no attribute show or hide, but even though we do have two counterparts in angular. If we spoke about ng-attr-enabled - then I would agree. But to me ng-enabled would be just a helper, just like ng-disabled and - as many have stated before - stand for readability which I bet all developers of angularjs fight and advocate for. |
+2048 |
Perhaps we should just have an ng-enabled fork of Angular JS. It’s almost worth it. -- On 11 Aug 2015 at 08:07:03, dokuboyejo ([email protected]) wrote: +2048 — |
@dokuboyejo It's so obvious It hurts!! ;) |
👍 |
1 similar comment
+1 |
We have provided this feature in an external module, thanks to Angular core member @btford : https://github.com/btford/angular-enabled |
Should this attribute be created in a future release?
The text was updated successfully, but these errors were encountered: