I want to disable the up and down keys for a number input through angularjs directive (or otherwise).
Note: I don't want to change the input type to text as I have been asked not to.
I already removed the spinners too.
I am new to angular so don't know much about it. I googled through all the links I could find but they were mostly about hiding the spinners and not about disabling the arrow keys.
I got this code from some other link. This disables the mousewheel for the same. If some changes to this can be done, that will be great.
module.directive('input',function() {
return {
restrict: 'E',
scope: {
type: '@'
},
link : function (scope, $element) {
if (scope.type == 'number') {
$element.on('focus', function () {
angular.element(this).on('keyup', function (e) {
e.preventDefault();
});
});
$element.on('blur', function () {
angular.element(this).off('keyup');
});
}
}
}
});