Chapter 9: Combining watchers with $watchGroup

HTML

<script src="https://code.angularjs.org/1.3.2/angular.min.js"></script>
<div ng-app="myApp">
    <div ng-controller="Ctrl">
        <input ng-model="myPlanet" />
        <div ng-repeat="date in otherPlanet">
           <input ng-model="date" />
        </div>
    </div>
</div>

JavaScript

angular.module('myApp',[])
.controller('Ctrl', function($scope, $log) {
  $scope.myPlanet = 'Earth';  
$scope.otherPlanet = ['Venus','Jupiter','Mars'];
     
    
    // watch ping and the ding.dong property by reference
    $scope.$watchGroup([$scope.myPlanet, $scope.otherPlanet], function(newVals, oldVals, scope) {
        // callback logic
        $log.log(newVals, oldVals, scope);
    });
});