Skip to content

Instantly share code, notes, and snippets.

@marcorinck
Created August 25, 2013 07:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcorinck/6332440 to your computer and use it in GitHub Desktop.
Save marcorinck/6332440 to your computer and use it in GitHub Desktop.
AngularJS directive blueprint
var myModule = angular.module(...);
myModule.directive('directiveName', function (injectables) {
return {
restrict: 'A',
template: '<div></div>',
templateUrl: 'directive.html',
replace: false,
priority: 0,
transclude: false,
scope: false,
terminal: false,
require: false,
controller: function($scope, $element, $attrs, $transclude, otherjectables) { ... },
compile: function compile(tElement, tAttrs, transclude) {
return {
pre: function preLink(scope, iElement, iAttrs, controller) { ... },
post: function postLink(scope, iElement, iAttrs, controller) { ... }
}
},
link: function postLink(scope, iElement, iAttrs) { ... }
};
});
http://amitgharat.wordpress.com/2013/06/08/the-hitchhikers-guide-to-the-directive/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment