9. What is the purpose of the $watch?

The purpose of $watch is to keep track of the old and new value of the watched expression. Below is the code of using $watch.

$scope.$watch(“checkInDate”, function (newValue, oldValue) {
console.log(“I’ve changed : “, newValue);
});

Leave a Reply