i am facing an issue where i have a directive sitting on an input type=number, those with side arrows for selecting numbers up and down.
I am using HostListener but I can't find a way to target the specific event when the user clicks on the side arrows.
So far I have tried:
@HostListener(change'): does not work at all
@HostListener('ngModelChange'): cause an infinite loop when the user uses the keyboard after
@HostListener('click'): It's the only one the works but the event does not contain the input value as it is a generic click event.
@HostListener('input'): Only works when the users input a number using the keyboard
Does anyone know the official way of getting this event?
@HostListener('input', ['$event'])
onEvent(event) {
this._propagateTouch();
this._propagateChange(event.target.value);
// console.log('input');
}
@HostListener('click', ['$event'])
onChange(event) {
this._propagateTouch();
this._propagateChange(event);
console.log('arrow change');
}
@HostListener('keydown', ['$event'])
handleKeyboardEvent(event) {
this._propagateTouch();
this._propagateChange(event.target.value);
}