Reputation: 910
I know how ngRepeat uses hash keys to not rerender elements, I am storing a simple array of strings, and I would like to force the re render of the dom , is there a simple way to do it?
to force ng-repeat to re render itself even though my string array havn't changed?
Why :
$scope.image = "image/jpg..."
$scope.confs = ['glow','sepia','brighten']
<div ng-repeat="conf in confs">
<div my-directive="conf">
</div>
I want to rerun the ng-repeat when the image changes, not when the conf change
Upvotes: 0
Views: 3820
Reputation: 1561
In this case, you don't actually want ng-repeat
to rerender, because it will produce exactly the same output: three my-directive
divs. Howeer, you DO want all my-directive
s to rerender, because something they depend on has changed.
What you can do in your directive is set up a $watch
on your scope. For example, in my-directive
's link
function,
scope.$watch(
function thingToWatch(){ return $scope.image; },
function whatToDo(image){ .../*your code using image here*/... }
);
Now, when $scope.image changes, your directives will all update themselves.
Upvotes: 3