您的位置:首页 > Web前端 > AngularJS

AngularJS directive 指令相关记录

2016-12-14 22:48 746 查看
....

.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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: