I've been doing a lot of research online, but all the solutions I find are using jquery
. I'm still getting the hang of Angular and Typescript. I found this and this to be unhelpful. I built a monthpicker from scratch, which has a simple and clear process. When I click on the input
field, a popup containing all the months opens up. Something like this:
https://i.sstatic.net/qgZui.png
This popup is actually using p-overlay
from the primeng
library. Here is my code snippet.
monthpicker.component.html
<textbox
(click)="openMonthpicker.toggle($event)">
</textbox>
<p-overlayPanel class="dropdown" #openMonthpicker>
HTML CODE TO DISPLAY THE MONTHS
</p-overlayPanel>
My monthpicker component is editable, meaning you can input dates through the keyboard. However, I want the popup to close when entering dates. I added this line of code in the textbox
:
<textbox
...
(keydown)="openMonthpicker.off($event)">
</textbox>
It seems that the off
function is not working. I also tried using remove
, but I'm not sure what function to use to close the popup. Can anyone assist me with this issue?
PS: I also went through TypeScript Event Handlers.