Skip to main content

Posts

Showing posts with the label What is $watch in angular?

How to use AngularJs $watch?

What is $watch in  angular? Hello everyone, I am going to share the example for using angular $watch. The angular create watch internally. The watch means that angular watches the changes in the variable on the $scope object. The watches are created using the   $scope.$watch()   method and the   $scope.watch()   method creates a watch of some variables.  When you register a watch you need to pass two functions         1. One is value function.         2. And other is listener function. The live demo example link, go to http://embed.plnkr.co/X1zenc/preview How to use $watch in angular? The example in detail as given below The Angular code-sample  var   app = angular.module( "mywatch" , []);   var   myController = app.controller( "watchController" ,   function   ($scope) {          ...