https://www.cnblogs.com/lvdabao/p/3391634.html
myModule.directive('namespaceDirectiveName', function factory(injectables) {
var directiveDefinitionObject = {
restrict: string,//指令的使用方式,包括標籤,屬性,類,註釋
priority: number,//指令執行的優先級
template: string,//指令使用的模板,用HTML字符串的形式表示
templateUrl: string,//從指定的url地址加載模板
replace: bool,//是否用模板替換當前元素,若爲false,則append在當前元素上
transclude: bool,//是否將當前元素的內容轉移到模板中
scope: bool or object,//指定指令的作用域
controller: function controllerConstructor($scope, $element, $attrs, $transclude){...},//定義與其他指令進行交互的接口函數
require: string,//指定需要依賴的其他指令
link: function postLink(scope, iElement, iAttrs) {...},//以編程的方式操作DOM,包括添加監聽器等
compile: function compile(tElement, tAttrs, transclude){
return: {
pre: function preLink(scope, iElement, iAttrs, controller){...},
post: function postLink(scope, iElement, iAttrs, controller){...}
}
}//編程的方式修改DOM模板的副本,可以返回鏈接函數
};
return directiveDefinitionObject;
});