Created
February 10, 2014 05:09
-
-
Save awhitty/8910661 to your computer and use it in GitHub Desktop.
Quickly toggling classes with Angular
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
<!-- Parent --> | |
<div ng-class="{true: ‘these classes when true’, false: ‘these classes when false’}[variable]"> | |
<!-- Child --> | |
<button ng-click="variable = !variable">Toggle me bro</button> | |
</div> | |
<!-- Shorthand when just toggling visibility --> | |
<div ng-toggle="variable"> | |
<!-- Child --> | |
<button ng-click="variable = !variable">Toggle me bro</button> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment