$watch in AngularJS — a practical guide to AngularJS $watch with clear examples you can reuse in real projects.
AngularJS Tutorial Series (88/99). Prefer one article? Read the complete AngularJS tutorial.
Short description
Deep watches (objectEquality true) are expensive — use carefully.
$watch
var off = $scope.$watch('vm.query', function (nv, ov) {
if (nv !== ov) { vm.search(nv); }
});
$scope.$on('$destroy', off);