Skip to content

Instantly share code, notes, and snippets.

@ryardley
Last active August 29, 2015 14:13
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 ryardley/479cc146e980b662c6b9 to your computer and use it in GitHub Desktop.
Save ryardley/479cc146e980b662c6b9 to your computer and use it in GitHub Desktop.
app.directive('myOverlayer', function(ElementRegistry){
return {
link: function(scope, element, attrs){
var content, background,
registry = new ElementRegistry(scope);
registry.find('button', function(button){
button.on('click', function(){
scope.overlayShowing = !scope.overlayShowing;
});
});
registry.find('content', function(elem){
content = elem;
});
registry.find('background', function(elem){
background = elem;
});
scope.$watch('overlayShowing', function(showing){
var display = showing ? 'block' : 'none';
if(content) { content.css('display', display) }
if(background) { background.css('display', display) }
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment