When you're using a $watch method (with equality by value). Is there a way to see which object property was changed?
e.g.
/**
* Save state of button: Cancelled
*/
$scope.$watch('buttons.cancelled', function(newValue, oldValue) {
if(newValue != oldValue && newValue !== undefined) {
privates.viewState.buttons.cancelled = $scope.buttons.cancelled;
}
});
/**
* Save state of button: Booked
*/
$scope.$watch('buttons.booked', function(newValue, oldValue) {
if(newValue != oldValue && newValue !== undefined) {
privates.viewState.buttons.booked = $scope.buttons.booked;
}
});
Turned into;
$scope.$watch('buttons', function(newValue, oldValue) {
if(newValue != oldValue && newValue !== undefined) {
//Is there a way to know which button triggered this watch?
}
}, true);