Sibi Raj Sibi Raj - 2 months ago 35
AngularJS Question

Watching any changes in ngmodel

I have defined ng-model ad

<input type="checkbox" name="check" ng-model="params.privacy">

I have my controller code as

status: false

How to watch any changes of the terms inside the $scope.params


You can do it like this:

$scope.$watch('params.privacy', function(new, old) {
   // triggered when `params.privacy` is changed

Or if you want to watch all properties, use deep watch:

$scope.$watch('params', function(new, old) {
   // triggered when any `params` property is changed
}, true);