I am experiencing an issue with a dropdown functionality. When a user selects an option and then presses either the "Delete" or "Backspace" button on the keyboard, the value from the dropdown clears which is working correctly. However, I am attempting to implement a Directive that achieves the same effect but I am facing challenges in making it work. Can anyone provide guidance on how to properly create this directive?
Thank you in advance for your help!
Below is the code snippet:
onKeyUp(evt){
if(evt.keyCode === 8){
this.isShowClear = false;
let currentElementName = evt.currentTarget.getAttribute('name');
this.myForm.controls[currentElementName].patchValue('');
}
}
onChange(){
this.isShowClear = true;
}