[英]how to access outer scope inside the ng-repeat in a directive
I have a directive, inside a link function, i have a scope variable which I need to access inside 'ng-repeat'. 我在链接函数中有一个指令,我在'ng-repeat'中需要访问一个范围变量。 But it is not picking up the value.
但这并没有增加价值。
I have tried using $parent also went through couple of answers, but still it doesn't work. 我尝试使用$ parent也经历了几个答案,但仍然行不通。
This is what I tried: 这是我尝试的:
HTML: HTML:
<div ng-controller="MyCtrl">
<div my-directive ng-repeat="item in items" item='item'></div>
</div>
Fiddle Link: 小提琴链接:
You gotta pass scope to your link function: 您必须将范围传递给链接函数:
link: function(scope){
scope.val = "thing"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.