2

ng-change even not firing on text box backspace button press.

ng-change works fine on changing the value example pressing numbers or any character from keyboard but not on backspace button press

Veera Induvasi
  • 822
  • 7
  • 19

2 Answers2

2

try like this.

var app = angular.module("app",[])
app.controller('ctrl',['$scope', function($scope){
     
  
  $scope.test = function(model){
    console.log(model);
    
    }
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
<div class="item item-checkbox">
   <input type="text" ng-model="model" ng-change="test(model)">
   {{model}}
</div>
Hadi J
  • 16,989
  • 4
  • 36
  • 62
1

The ngChange expression is only evaluated when a change in the input value causes a new value to be committed to the model.

It will not be evaluated:

  • if the value returned from the $parsers transformation pipeline has not changed
  • if the input has continued to be invalid since the model will stay null
  • if the model is changed programmatically and not by a change to the input ngChange will nor get fired when you press spacebar, if you enter character or number followed by space then it will get fired.

Please send code or example so that I can help you more.... Refer: https://docs.angularjs.org/api/ng/directive/ngChange

Rocky
  • 48
  • 6