Created
June 11, 2014 09:36
-
-
Save cpoDesign/e37c78a8e5f4da71b45b 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 hidden or 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
| // 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