创作了一段指令代码。让其子指令可以通过它的controller来做一些事情。大致代码如下
//check-list指令并未设置模板。
angular.module('webApp')
.directive('checkList', function () {
return {
restrict:'A',
scope:{
allCheck:'@',
getChecks:'='
},
controller:function($scope){
//业务逻辑
}
}
angular.module('webApp')
.directive('mainCheckbox', function (){/*业务逻辑*/})
angular.module('webApp')
.directive('subCheckbox', function (){})
指令为了实现通过mainCheckBox单选全选subCheckBox的功能。
html代码大致如下:
<table check-list>
<thead>
<tr>
<th><input type="checkbox" main-checkbox/></th>
<th>ID</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items">
<td><input type="checkbox" sub-checkbox"/></td>
<td> <a href="#">{{item.id}}</a></td>
</tr>
</tbody>
</table>
因为用了UIRouter,在文件中配好了该页面所对应的控制器。
我想问的是该控制器对应了一个$scope。
本例中ng-repeat的数据就是从该控制器中获取的。
但是我在指令中也声明了check-list的作用域为独立作用域。
那么此例中的table作用域应该属于check-list吧?可是经过测试,
该table的作用域并没有变成check-list的独立作用域。不是节点跟作用域相关联的吗?
求指导一下?这个作用域到底是怎么联系起来的。
方法里面的require依赖父集控制器,通过父类暴露的controller,在子类link中调用