Skip to content

Instantly share code, notes, and snippets.

@wishfoundry
Created January 12, 2014 16:56
Show Gist options
  • Save wishfoundry/8387308 to your computer and use it in GitHub Desktop.
Save wishfoundry/8387308 to your computer and use it in GitHub Desktop.
experimenting with ways to decorate angular directives. The disadvantage here is you apply this to all directives
app.config(function($provide) {
$provide.decorator('fooDirective', function($delegate) {
var directive = $delegate[0];
if(directive.restrict.indexOf('E') >= 0) {
makeElement(toDashCase(name))
}
function toDashCase(str) {
return (str.charAt(0) + string.slice(1).replace(/([A-Z])/g, "-$&")).toLowerCase()
}
function makeElement(name) { // enable custom elements hack for IE
var node = document.createElement(name);
}
return $delegate;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment