verto-health / ngx-turnstile

Cloudflare Turnstile for Angular
https://ngx-turnstile.pages.dev/
MIT License
61 stars 12 forks source link

Reset in Component #24

Closed willfarias closed 7 months ago

willfarias commented 8 months ago

Is there any way to use a reset method within a component? At the moment I'm using it in an insecure way: eval("turnstile.reset()");

choyiny commented 7 months ago

Updating the control value to null will reset the component. Let me know if this works for you :)

willfarias commented 7 months ago

Updating the control value to null will reset the component. Let me know if this works for you :)

I don't think I understood what you meant, can you post an example code?

choyiny commented 7 months ago

Click on "Reset Form Control" or "Set to Invalid Value" on this example page to see turnstile widget refreshing itself: https://ngx-turnstile.pages.dev/reactive-form-example

willfarias commented 7 months ago

@choyiny Thank you very much, I was using event binding, I changed it to formcontrol and solved it using one of the solutions in the example.