o(* ̄︶ ̄*)o

  博客园  :: 首页  ::  :: 联系 :: 订阅 订阅  :: 管理
var myModule = angular.module(...); 
  
myModule.directive('directiveName', function factory(injectables) { 
  
 var directiveDefinitionObject = { 
  
   priority: 0,    //指令优先级
  
   template: '<div></div>',  //函数(返回值必须是字符串)或者字符串
  
   templateUrl: 'directive.html', //路径
  
   replace: false,  //是否替换标签
  
   transclude: false, //是否被模板替换
  
   restrict: 'A',  //取值类型,E(元素),A(属性),C(类),M(注释),可以共用如:'EA'
  
   scope: false, //作用域
  
   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) { ... } 
  
}; 
  
 return directiveDefinitionObject; 
  
}); 

  

posted on 2019-04-01 20:59  熊本熊の熊  阅读(300)  评论(0编辑  收藏  举报