Using $watchCollection to Track Changes to Properties of an Object in the Scope

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;
});

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset