javascript - ng-change doesn't trigger on number input type -


I am using angularJS, and if the input value is not the number then I get an error to pop up I am trying to

  Number value: & lt; Input type = "number" ng-model = "mydata.number" ng-change = "check number ()" /> & Lt; P style = "color: red" ng-show = "number error" & gt; {{NumberError}} & lt; / P & gt;   

and then inside $ scope.checkNumber I check to see if this is invalid:

  if (! $ Scope.mydata .number || isNaN ($ scope.mydata.number)) {$ scope.numberError = "This should be a number"; }   

It appears that when I initially does not enter an error popup in a string like "fff", and we do not enter the checknumber function, but if i "1fff "Entering the function enters the function and shows an error as it should

If the input type is the number and the initial letter number is not, then does the NG-model change not ?

About using an angular built-in verification like this:

 < Code> & lt; Form name = "myForm" & gt; Number value: & lt; Input type = "number" ng-model = "mydata.number" name = "myNumber" /> & Lt; P style = "color: red" ng-show = "myForm.myNumber. $ Dirty & myForm.myNumber. $ Valid" & gt; {{NumberError}} & lt; / P & gt; & Lt; / Form & gt;    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -