Skip to content

Instantly share code, notes, and snippets.

@bbrown
Created June 30, 2015 19:12
Show Gist options
  • Select an option

  • Save bbrown/0e23b040282f5d3e6f54 to your computer and use it in GitHub Desktop.

Select an option

Save bbrown/0e23b040282f5d3e6f54 to your computer and use it in GitHub Desktop.
Angular directive that toggles the specified class on click
angular.module("app").directive("toggleClass", function()
{
return {
restrict: "A",
link: function(scope, element, attrs)
{
element.bind("click", function()
{
element.toggleClass(attrs.toggleClass);
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment