Last active
August 29, 2015 14:02
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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