0

I have a directive, inside a link function, i have a scope variable which I need to access inside '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.

This is what I tried:

HTML:

<div ng-controller="MyCtrl">
    <div my-directive ng-repeat="item in items" item='item'></div>
</div>

Fiddle Link:

Demo

  • For more info, you can check this answer: http://stackoverflow.com/questions/17561632/how-to-modify-scope-from-within-a-directive-in-angularjs – Alberto Rivera Sep 07 '16 at 00:49

1 Answers1

1

You gotta pass scope to your link function:

link: function(scope){
        scope.val = "thing"
}

http://jsfiddle.net/p86qjryq/

Alberto Rivera
  • 3,652
  • 3
  • 19
  • 33