angular,mvc指令的嵌套使用

关于指令嵌套的使用,取值问题。

原理类似于控制器中使用指令,父指令类似于控制器,子指令就类似于控制器中指令。通过传值方式‘=’,我们直接可以在父指令中获取数据

举一个例子:

有个指令parentDirective
模板文件是:parentHtml还有一个childDirective
myapp.directive("childDirective",[function(){
  return{
template:'....../childHtml',
link:function(){
ngModel:'='
}
} }]);
模板文件:childHtml
在parentDirective中引入childDirective
myapp.directive("parentDirective",
'.../js/directive/childDirective'
[function(){ return{
template:'....../parentHtml.html',
link:function(s,el,attr){
s.$watch('giveData',function(n,o){
         console.log(n);     
      });
}
} }]);
parentHtml.html
<child-directive ng-model="giveData"></child-directive>

如果你想互相引用指令的控制器,你可以看看下面的文章链接

http://blog.csdn.net/zhoukun1008/article/details/51296692