Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
AngularJS $watch() Function Example
Keywords : How to use $watch() function in angularjs with example, Angularjs $watch() central function example, Angularjs $scope.$watch function example, Angularjs watch variable changes example
Example
<!DOCTYPE html> <html> <head> <title> AngularJs $watch() Function with Example </title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script type="text/javascript"> var app = angular.module('watchApp', []); app.controller('watchCtrl', function ($scope) { $scope.count = -1; $scope.$watch('txtval', function (newval, oldval) { $scope.count = $scope.count + 1; }); }); </script> </head> <body> <div ng-app="watchApp" ng-controller="watchCtrl"> <h2>AngularJS $watch() Function Example</h2> Enter Text:<input type="text" ng-model="txtval" /><br /><br /> <span style="color:Red">No. of Times $watch() Function Fired: {{count}}</span> </div> </body> </html>
Click Here to See Result
Result
Previous
Next