You can also watch the properties of an object using the $watchCollection
method. The $watchCollection
method takes an object as the first parameter and watches the properties of the object. In the case of an array, the individual values of the array are watched. For example:
$scope.scores = [5, 10, 15, 20];
$scope.$watchGroup('scores', function(newValue, oldValue) {
$scope.newScores = newValue;
});