Ng-Change-1

 

This is very simple example of the ng-change directive. In this we have a checkbox and on the change of the checkbox we increment the value of the count variable by 1. The value of count variable is increment by 1 as you checked and unchecked the checkbox and below the checkbox we display the value of isTrue variable which is bind with this checkbox.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="changeExample"> <div ng-controller="ExampleController"> <div class="container"> <div class="col-md-3 well"> Are you developer <input type="checkbox" ng-model="isTrue" ng-change="count=count+1" /> Count: {{count}} <pre>{{isTrue}}</pre> </div> </div> </div> <script> var app = angular.module("changeExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.isTrue = true; }]); </script> </body> </html>
Output