Monday, 7 January 2019

AngularJS ng-change directive


AngularJS ng-change directive

ng-change is use to evaluate when content is being changed by the user.
The ng-change directive requires an ng-model directive to be present.

Example:
<div ng-app="myApp1" ng-controller="Employee1Controller">
    <p>Name: <input ng-change="GetInfo()" type="text" ng-model="Name" /></p>
    <span style="color:blue">you have changed the value {{changecount}} times</span>
</div>

<script>
    var myapp = angular.module('myApp1', []);
    myapp.controller('Employee1Controller', function ($scope) {
        $scope.changecount = 0;
        $scope.GetInfo = function () {
            $scope.changecount++;
        }
    });
</script>