内置指令 及使用方法:
**replace 替换 **
**html模板写法 **
<hello><div>这里被替换没有了</div></hello>
指令写法
var myModule = angular.module(“myModule”,[])
myModule.directive(“hello”,function(){
return {
restrict:’AE’,
replace:”true”,
template:”<div>hello world </div>"
}
})
transclude 指令内部包含有元素的情况下指定该元素在指令元素的嵌套位置 很重要的功能,可以通过指令互相嵌套
html模板写法
<hello><div>这里是指令内部内容</div></hello>
指令写法
var myModule = angular.module(“myModule”,[])
myModule.directive(“hello”,function(){
return {
restrict:’AE’,
transclude:”true”,
template:”<div>hello world <div ng-tranclude></div></div>"
}
})
scope的绑定策略
@ 把当前属性作为字符串来传递。你还可以绑定来自外层scope的值。在属性值中插入{{}}即可。
= 与父scope中的属性进行双向绑定
& 传递一个来自父scope的函数,稍后调用