myModule.directive('namespaceDirectiveName', function factory(injectables) {
var directiveDefinitionObject = {
restrict: string,
priority: number,
template: string,
templateUrl: string,
replace: bool,
transclude: bool,
scope: bool or object,
controller: function controllerConstructor($scope, $element, $attrs, $transclude){...},
require: string,
link: function postLink(scope, iElement, iAttrs) {...},
compile: function compile(tElement, tAttrs, transclude){
return: {
pre: function preLink(scope, iElement, iAttrs, controller){...},
post: function postLink(scope, iElement, iAttrs, controller){...}
}
}
};
return directiveDefinitionObject;
});
公众号“ Alili丶前端大爆炸”,关注后提供海量学习资料
![图 1](https://i-blog.csdnimg.cn/blog_migrate/744be522382b2003f573c0456ae9871d.png)