Created
February 4, 2014 22:27
-
-
Save rolaveric/8813637 to your computer and use it in GitHub Desktop.
A simplified implementation of the ng-hide directive, to illustrate directive testing.
This file contains 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.directive('ngHide', [function () { | |
return function (scope, element, attr) { | |
scope.$watch(attr.ngShow, function ngHideWatchAction(value){ | |
// Call "addClass()" or "removeClass()" based on the attribute value | |
// AngularJS already declares the CSS for the "ng-hide" class | |
element[value ? 'removeClass' : 'addClass']('ng-hide'); | |
}); | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment