0

Hello I need help for angularjs.

I want to trigger ng-change on input type number input field.

 <input 
   ng-required="true"
   ng-change = "onChangePrePay()"
   type="number"
   ng-model="entry.team.prepaidEntriesNum"
  />

but on-change is triggered only when input field loses focus. Any idea how to override this behavior. It's totally unexpected.

4
  • 1
    your code doesn't have ng-change in it Commented Nov 5, 2018 at 16:18
  • typo still not working Commented Nov 5, 2018 at 17:10
  • There must be something else wrong because this is generally not a problem: jsfiddle.net/sh0ber/ckx1346m Commented Nov 5, 2018 at 17:25
  • tnx for helping you are right, i will let you know tomorrow after inspection the code Commented Nov 5, 2018 at 17:33

3 Answers 3

3

var app = angular.module('myApp',[]);
app.controller('ctrlMain',function($scope){
	 $scope.test = 23;	
   $scope.onChangePrePay = function(){
       alert('CHANGE');
   }
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular.min.js"></script>

<body ng-app="myApp">
    <div ng-controller="ctrlMain">
        <input 
         ng-required="true"
         ng-OnChange = "onChangePrePay()" */change here in your code ng-OnChange instead of ng-change
         type="number"
         ng-model="test"
        />
    </div>
</body>

Sign up to request clarification or add additional context in comments.

Comments

0

to check trigger change on the input use ng-change not ng-onchange

Comments

0

replace "ng-onchange" with "ng-change"

3 Comments

yeah thats the whole point of my question, it's well known issue but some noob down voted my question
try this : w3schools.com/angular/tryit.asp?filename=try_ng_ng-change if you change the input type to number, the change method works
tnx for helping you are right, i will let you know tomorrow after inspection the code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.