You’re using AngularJS with some form and don’t want to hassle with event listeners when changing a property of an object. Usually, the ng-change directive works only with the new value of whatever you toss at it, but you can send the old value as well.
Simply add curly brackets to the parameter and it’ll send a copy of the old untouched data.
The function declaration of setChangedStatus looks like this:
$scope.setChangedStatus = function(newValue, oldValue) { // newValue contains the entire object after the change // oldValue contains the entire object before the change // note: don't set any values in oldValue, as they will get lost }
This might be helpful, if you need to compare a number of other properties in the car object and need to respond to that.