Ng-Change-4

 

In this example we have a textbox and when you type in the textbox the value changes and on the change of the value we increment the value of count variable by 1 by calling function on the change event using the ng-change directive. The value of count variable is display below the textbox.

 
 
 
<!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" ng-init="count=0"> Male: <input type="radio" ng-model="radio1" value="Male" ng-change="layout(radio1)" /> Female: <input type="radio" ng-model="radio2" value="Female" ng-change="layout(radio2)" /> <pre><b>Changed</b> {{radio1}} </pre> </div> </div> </div> <script> var app = angular.module("changeExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.layout = function (rdo) { $scope.radio1 = rdo; $scope.radio2 = rdo; } }]); </script> </body> </html>
Output