WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-change Directive


Example

Execute a capacity when the estimation of the info field changes:

<body ng-app="myApp">

<div ng-controller="myCtrl">
    <input type="text" ng-change="myFunc()" ng-model="myValue"/>
    <p>The input field has changed {{count}} times.</p>
</div>

<script>
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function($scope) {
    $scope.count = 0;
    $scope.myFunc = work() {
        $scope.count++;
    };
}]);
</script>

</body>
Try it yourself »

Definition and Usage

The ng-change mandate guides AngularJS when the estimation of a HTML component changes.

The ng-change mandate requires a ng-model mandate to be present.

The ng-change mandate from AngularJS won't abrogate the component's unique onchange occasion, both the ng-change articulation and the first onchange occasion will be executed.

The ng-change occasion is activated at each adjustment in the esteem. It won't hold up until all progressions are made, or when the info field loses focus.

The ng-change occasion is possibly activated if there is a genuine change in the info esteem, and not if the change was produced using a JavaScript.


Syntax

<element ng-change="expression"></element>

Supported by <input>, <select>, and  <textarea>.


Parameter Values

Value Description
expression An articulation to execute when a component's esteem changes.