ng2-iq-select2 icon indicating copy to clipboard operation
ng2-iq-select2 copied to clipboard

Reinitialize the component with new dataSourceProvider function

Open antoantonyk opened this issue 7 years ago • 2 comments

I was trying to show the ng2-iq-select2 options based on another ng2-iq-select2 selection. First time everything is working fine. But when i try to change the value of first one, the second drop down options will not change due to clientMode option set as true(i need to do it in client side). Is there any way to reinitialize the component with new dataSourceProvider function?

antoantonyk avatar Apr 24 '17 07:04 antoantonyk

I haven't tried but I think you should be able to do something like select2ComponentVariable.fullDataList = undefined; when you make the selection on the first component. There is a onSelect event generated that may be useful for that. Obviously, this isn't as elegant as I wanted it to be, but I think it should be a valid workaround. Will try to add a handy method to reset the loaded values manually for this cases.

diegofsza avatar Apr 24 '17 19:04 diegofsza

You can return a Subject from your dataSourceProvider and then just call subject.next([your new data array here]). We did this at work and it works like a charm :)

saithis avatar Jun 03 '17 09:06 saithis