I have the next problem, I created a directive in Angular JS to check if input is or not a number, If it isn't number is neccesary set the right value. Here is my directive code:
app.directive('numberValidate', function(){
return {
require: 'ngModel',
link: function($scope, element, attr, modelCtrl){
modelCtrl.$parsers.push(function (inputValue){
var transformedInput = parseInt(inputValue);
if (transformedInput!=inputValue) {
modelCtrl.$setViewValue(transformedInput);
modelCtrl.$render();
}
return transformedInput;
});
}
};
});
additional I need to listen when the user stop typping to send a request. To listen when stop I've added ng-model-options="{debounce: 750}" to the field, as it is on the next code:
<input type="text" ng-change="sendChecker()" ng-model="identification" ng-model-options="{debounce: 750}" number-validate>
sendChecker function fires my request to the server, everything is working Ok when I write a number like 12345 or I type a number with characteres 12345a this is converted to number and set in the input, The issue is when I write a letter a this creates a loop. How can I avoid this?
Any advice would be apreciated.
12345awould be12345.