Last active
August 29, 2015 13:57
-
-
Save Morgul/9425235 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ng-class style --> | |
<button class="btn btn-default" ng-keypress="{enter: doStuff, up-arrow: doStuff2}">Activate Me!</button> | |
<!-- dual attribtues --> | |
<button class="btn-default" ng-keypress="doStuff" key="up-arrow">Activate Me!</button> |
My issue with the first one is that you actually can't parse that as normal JS; since you have "doStuff()" and "doStuff2()", those would both get executed as soon as the attribute is parsed. Instead, they'd have to either be strings (that we'd run through eval
) or function definitions.
Oh, my bad. That's a typo.
See, Angular has support for this; this is exactly what they do in the ng-class
directive. So, I believe $parse
is what we'd be looking for... but we can check the code of ng-class
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@whitelynx Here's my thoughts on the api for a keypress directive.