Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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