Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carlware/87bff18db1bddda68d61 to your computer and use it in GitHub Desktop.
Save carlware/87bff18db1bddda68d61 to your computer and use it in GitHub Desktop.
.directive('directiveName', [function () {
var directiveDefinitionObject = {
priority: 0,
template: '<div></div>', // or // function(tElement, tAttrs) { ... },
// or
// templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... },
replace: false,
transclude: false,
restrict: 'A',
scope: false,
controller: ['$scope', '$element', '$attrs', '$transclude', 'otherInjectables', function($scope, $element, $attrs, $transclude, otherInjectables) {}],
require: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'],
compile: function compile(tElement, tAttrs, transclude) {
return {
pre: function preLink(scope, iElement, iAttrs, controller) { },
post: function postLink(scope, iElement, iAttrs, controller) { }
}
// or
// return function postLink( ... ) { ... }
},
// or
// link: {
// pre: function preLink(scope, iElement, iAttrs, controller) { },
// post: function postLink(scope, iElement, iAttrs, controller) { }
// }
// or
// link: function postLink( ... ) { ... }
};
return directiveDefinitionObject;
// or
// return function postLink( scope, iElement, iAttrs ) {};
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment