Created
June 30, 2015 19:12
-
-
Save bbrown/0e23b040282f5d3e6f54 to your computer and use it in GitHub Desktop.
Angular directive that toggles the specified class on click
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
| 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