-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Conversation
While playing with this directive I kept asking myself 2 questions:
Thoughts? |
var exprSetter = exprGetter.assign; | ||
|
||
//watch model changes | ||
scope.$watch(attrs.toggle, function(newVal){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just watch exprGetter, since angular will be $parsing it internally anyway if you provide an expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I got you here...
I don't think i like the automatic class=btn, it's too magical. Adding class=btn manually is no problem for me. And we should make it an attribute directive of name btn-toggle. Lots of people use anchor or div elements for their buttons. |
}); | ||
|
||
//watch click events | ||
element.bind('click', function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought of this, but we should be keeping click events out of our code. On mobile, they are bad (need a tap event). We should keep the events in template. Although here I'm not sure how to make the event mobile configurable... A template for this directive would be too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, adding event in a directive is bad... although I thought that it will react to tap events as well, need to test.
What worries me more is is the fact that the class name (active
) is hard-coded here.
I like the idea of this directive less and less :-)
Maybe we really should just do a generic class-toggle
and be done with it? WDYT?
Thnx @ajoslin for looking into it. I agree with getting rid of the automatic Maybe we should just do the
Or maybe we should abandon the idea of such a simple directive altogether and simply have demos for cases where a dedicated directive is too much? |
@pkozlowski-opensource As this is such a simple directive, I am more in favor it not existing and just incorporating example use cases, I think. For most buttons, the use case is too simple:
As for the toggling, which seems to be all the directive does, I agree with making a |
@joshdmiller Yes, I agree that the directive as submitted in this PR doesn't make much sense. I will just keep it open to continue the discussion but for sure it shouldn't be merged. But yes, a class-toggling directive might make sense. Could you work with me on the syntax? My current proposal was:
I don't know, maybe there is nothing to encapsulate here? |
Yeah, I don't think it's quite worth a directive. Sent from my iPhone On Jan 5, 2013, at 3:02 PM, Pawel Kozlowski notifications@github.com wrote:
|
After a little more thought, I agree: it's not worth it. That said, I do think having some examples like this one in the docs would be very beneficial. |
OK, so clearly this PR doesn't make much sense :-) Closing this one. The issue for buttons is still open, we can decide if we simply want to add some examples or think of another directive. |
Agreed. -- new angular user |
Proposal for #53