angularjs 指令

内置指令 及使用方法:

**replace 替换 **


**html模板写法 **

这里被替换没有了

指令写法

var myModule = angular.module(“myModule”,[]) 
myModule.directive(“hello”,function(){
     return {
          restrict:’AE’,
          replace:”true”,
          template:”
hello world
" } })

transclude 指令内部包含有元素的情况下指定该元素在指令元素的嵌套位置 很重要的功能,可以通过指令互相嵌套


html模板写法

  
这里是指令内部内容

指令写法

var myModule = angular.module(“myModule”,[])
myModule.directive(“hello”,function(){
     return {
          restrict:’AE’,
           transclude:”true”,
          template:”
hello world
" } })

scope的绑定策略


@ 把当前属性作为字符串来传递。你还可以绑定来自外层scope的值。在属性值中插入{{}}即可。
= 与父scope中的属性进行双向绑定
& 传递一个来自父scope的函数,稍后调用

你可能感兴趣的:(angularjs 指令)