valor-software / ng2-select

Angular based replacement for select boxes
http://valor-software.github.io/ng2-select/
MIT License
675 stars 586 forks source link

Click Event #570

Open Hasnain-Bukhari opened 7 years ago

Hasnain-Bukhari commented 7 years ago

Hi, I am using ng2-select and its working very fine. But the thing is I need to use click event. How can I use that. Before Selected event I want to fire Click event. Please help me in this way. Thanks

nikolasleblanc commented 7 years ago

I've asked for this too, here: https://github.com/valor-software/ng2-select/issues/555

nikolasleblanc commented 7 years ago

@Hasnain-Bukhari you can use the (mousedown) event, the problem with (click) is that it requires both (mousedown) and (mouseup) and (mouseup) never has the chance to fire since the element being clicked is replaced on (mousedown).

I'm using (mousedown) to track whether or not the select has been opened, and https://www.npmjs.com/package/angular2-click-outside to tell when it's been closed (referring back to (mousedown) so that I don't get false positives on the close.

nikolasleblanc commented 7 years ago

That said, it'd be pretty nice if this library could simply emit a custom click event. :)