Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created October 28, 2013 12:23
Show Gist options
  • Save thekarel/7195934 to your computer and use it in GitHub Desktop.
Save thekarel/7195934 to your computer and use it in GitHub Desktop.
app.directive('bubble', function() {
return function(scope, element, attrs) {
// Whatever the data-bubble attr is set to will
// be the expression we watch.
var expr = attrs.bubble;
scope.$watch(expr, function(val) {
if (val > 0) {
element.attr('data-bubble', val);
} else {
element.removeAttr('data-bubble');
}
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment