I have a controller:
MyController
- $scope.value = 5
- $scope.list = [
{item: Apple, cost: 5},
{item: Bannana, cost: 2}
]
In my index.html I have an ng-repeat on:
<div ng-controller="MyController">
<mydirective ng-repeat="item in list" value="value"></mydirective>
</div>
In my directive, I have an isolate scope:
{
value:"="
}
In the linking function of the directive I have an bind to an event:
- Onclick, increment scope.value by "1"
The issue is it appears that despite the "=", each of the 2 directives generated from ng-repeat are merely "copies" of the actual MyController "value" variable. How do I make it such that they are linked together so that when I click, the $scope.value of myController gets updated and all the directive "scope.value" would match it? Or is this not possible?
I want to be able to watch on $scope.value of MyController from all the directives so that each of the directives can do something based on "value".