AngularJS directive 指令相关记录

....

.directive('scopeDemo',function(){

  return{

    template: "<div class='panel-body'>Name: <input ng-model=name /></div>",

    scope:true  // 设置scope属性为true将允许我在同一个控制器里复用这个指令

    scope:{}  //创建一个隔离的作用域

     scope:{local: "=nameprop" ,cityFn: "&city" } // local属性的值以一个@字符作为前缀,指定了属性local的值应该从一个来自名为nameprop的特性的双向绑定来获得
//前缀 & 告诉AngularJS 我想将所指定特性的值绑定到一个函数
   scope:{local: "@nameprop"}  // local属性的值以一个@字符作为前缀,指定了属性local的值应该从一个来自名为nameprop的特性的单向绑定来获得
   
   transclude: true
// 设置transclude为true后,会对指令所应用到的元素内容进行包装,但并不是元素本身。如果想包含进元素,就需要将transclude属性
   设置为element。
  
   require: "^productTable" //require定义对象属性用于声明对控制器的依赖

  }

})

可用于require属性值勤的前缀
前缀 描述
None   asf
^ asdf
? adf
原文地址:https://www.cnblogs.com/thomaspha/p/6181438.html