Skip to content

Instantly share code, notes, and snippets.

@awhitty
Created February 10, 2014 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awhitty/8910661 to your computer and use it in GitHub Desktop.
Save awhitty/8910661 to your computer and use it in GitHub Desktop.
Quickly toggling classes with Angular
<!-- 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