Skip to content

Instantly share code, notes, and snippets.

@marcorinck
Created Aug 25, 2013
Embed
What would you like to do?
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