Created
May 9, 2014 05:49
-
-
Save ashmind/d58c65d198c193981969 to your computer and use it in GitHub Desktop.
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('...').directive('ancestorClass', function() { | |
'use strict'; | |
function link(scope, element, attrs) { | |
var targets = element.parents().filter(attrs.selector); | |
scope.$watch(attrs.class, function(value) { | |
for (var key in value) { | |
targets.toggleClass(key, value[key]); | |
} | |
}, true); | |
}; | |
return { | |
link: link, | |
restrict: 'E' | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment