今日总结:
- restrict 匹配模式
- replace 与 transclude
- compile 与 link 函数
- 指令中的 scope 绑定
restrict 匹配模式
replace 与 transclude
replace:true 表示该指令内容会替换之前存在的内容
transclude:true 配合指令ng-transclude 指令使用 表示之前存在的内容会存放在含有ng-transclude指令的div容器中,从而让不同指令之间可以嵌套使用
complie 与 link 函数的区别
指令中的scope绑定
scope 用于创建每个指令之间独立的作用域,也用于指令与指令之间的交互
@ 绑定
= 绑定
& 绑定