【发布时间】:2017-04-08 19:22:50
【问题描述】:
简单的问题,但我无法在此模板中找到为什么 format-property 指令无法访问设备?
<table>
<tr ng-repeat="device in devices">
<format-property ng-repeat="property in properties"></format-property>
</tr>
</table>
尽管使用此模板它可以工作:
<table>
<tr ng-repeat="device in devices">
<td ng-repeat="property in properties">
<format-property></format-property>
</td>
</tr>
</table>
我试过scope.device 和scope.$parent.device 没有成功。
这是我的demo
编辑
我可以访问property,但不能访问device。不像this question,我有一个嵌套的ng-repeat
这里是一个新的demo,具有隔离范围
【问题讨论】:
-
从您的演示中,您似乎正在重新创建一个控制器和一个 $scope 并尝试调用它。您只需传递处理设备和属性 ng-repeats 的控制器。
-
不,范围是本地范围(ng-repeat的范围)。我可以从指令访问
property -
第二个工作正常。
-
是的,但这不是我想要的!
-
你到底想要什么?
标签: angularjs angularjs-directive