$watch() The $scope.watch() function is used to observe changes in a variable on the $scope. It accepts three parameters: expression, listener and equality object where listener and equality object are optional parameters. <html> <head> <title>AngularJS Watch</title> <script src="lib/angular.js"></script> <script> var myapp = angular.module("myapp", []); var myController = myapp.controller("myController", function ($scope) { $scope.name = 'nikssangani.blogspot.in'; $scope.counter = 0; $scope.$watch('name', function (newValue, oldValue) { $scope.counter = $scope.counter + 1; }); }); </script> </head> <body ng-app="myapp" ng-controller="myController"> <input ng-model="name" type="text" /> Counter: </body> </html> $digest() The $scope.$digest() function iterates through a
Here you can find solution of your code problem & errors.