Skip to content

Instantly share code, notes, and snippets.

@leandroh
Created February 18, 2016 16:54
Show Gist options
  • Select an option

  • Save leandroh/a02db5e48e11d541e013 to your computer and use it in GitHub Desktop.

Select an option

Save leandroh/a02db5e48e11d541e013 to your computer and use it in GitHub Desktop.
Directive Definition Object
var app = angular.module('app', []);
app.directive('webComponent', function factory(dependencias) {
var directiveDefinitionObject = {
priority: 0,
template: '<div></div>', // or // function(tElement, tAttrs) { ... },
// or
// templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... },
transclude: false,
restrict: 'A',
templateNamespace: 'html',
scope: false,
controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... },
controllerAs: 'stringIdentifier',
bindToController: false,
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;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment