Skip to content

Instantly share code, notes, and snippets.

@niceaji
Created September 13, 2014 15:19
Show Gist options
  • Save niceaji/9d0c35239427bafd0a03 to your computer and use it in GitHub Desktop.
Save niceaji/9d0c35239427bafd0a03 to your computer and use it in GitHub Desktop.
directive example
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, otherInjectables) { ... },
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) { ... }
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment