监视多个$scope属性
2022-08-29 23:15:05
						有没有办法订阅多个对象上的事件$watch
例如:
$scope.$watch('item1, item2', function () { });
有没有办法订阅多个对象上的事件$watch
例如:
$scope.$watch('item1, item2', function () { });
从AngularJS 1.3开始,有一个名为$watchGroup的新方法,用于观察一组表达式。
$scope.foo = 'foo';
$scope.bar = 'bar';
$scope.$watchGroup(['foo', 'bar'], function(newValues, oldValues, scope) {
  // newValues array contains the current values of the watch expressions
  // with the indexes matching those of the watchExpression array
  // i.e.
  // newValues[0] -> $scope.foo 
  // and 
  // newValues[1] -> $scope.bar 
});
 
				    		 
				    		 
				    		 
				    		