angularjs - ng-change trigger event when ng pattern condition changes from true to false -


problem:

ng-change getting triggered when pattern changing true false.

example:

pattern valid value minimum 10 digits when digits count changing 9 10 ,event fired correct. if 1 digit deleted again event fired. should not happen or might missing here.

my code like:

input id="id1" class="ng-pristine ng-invalid ng-invalid-required    ng-valid-pattern" type="text" ng-focus=""     ng-pattern="/^[0-9]{10,19}$/" required=""    ng-change="event1(method1.id1)" ng-model="method1.id1"   placeholder="1234123412341*"    ng-class="{'active': !method21.id1.$pristine}" name="id1" 

does 1 have solution this?

try this, problem ng-change function triger before value change

var jimapp = angular.module("mainapp",  []);    jimapp.controller('mainctrl', function($scope){    $scope.method1 = {};    $scope.event1 = function(id){      if(angular.isdefined(id)){        alert(id);      }          };  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <div ng-app="mainapp" ng-controller="mainctrl">    <form>      <input id="id1" class="ng-pristine ng-invalid ng-invalid-required     ng-valid-pattern" type="text" ng-focus=""      ng-pattern="/^[0-9]{10,19}$/" minlength="10" required     ng-change="event1(method1.id1);" ng-model="method1.id1"    placeholder="1234123412341*"     ng-class="{'active': !method21.id1.$pristine}" name="id1">    </form>  </div>


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -