Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Last active August 29, 2015 14:02
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 cpoDesign/0223dc05141aacc27b88 to your computer and use it in GitHub Desktop.
Save cpoDesign/0223dc05141aacc27b88 to your computer and use it in GitHub Desktop.
Example of creating directive that adds html to start and end of template.
// used in: http://blog.cpodesign.com/blog/angular-directives-in-examples/
// use example: <my-button>
testApp.directive('myButton', function(){
return {
link: function (scope, element, attrs) {
var markup = "<button>Hello</button>";
element.prepend(markup); // adds html before any child
element.append(markup); // adds html after last child
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment