0

If i had a scope like this one

$scope.array = [ { a: 1, b: 2 }, { a: 2, b: 1 }];

With a view:

<div>A:
  <div ng-repeat="obj in array">{{obj.a}}</div>
</div>

Having in mind that the expression {{obj.a}} is served vía the ng-repeat directive, my question is if the AngularJS watcher behind the expression {{obj.a}} will execute if i change obj.b like this

$scope.players[0].b = 666

In other words, having an array of objects drawn in the screen, if i change an attribute that is not binded to the view of one of those objects, ¿will the view try to redraw itself anyway?

1 Answer 1

1

No, the interpolation is using the $parse service to figure out what to watch on. It will only update that text node when obj.a changes.

It is similar to writing $scope.$watch("obj.a", handler). In this case, it is evaluating that statement on every digest. If the result of that statement changes, then it will call your function. In the case of interpolation, the callback function then updates the DOM.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.