diff --git a/projects/ng-hcaptcha/src/lib/ng-hcaptcha-invisible-button.directive.ts b/projects/ng-hcaptcha/src/lib/ng-hcaptcha-invisible-button.directive.ts index 6ea2e1b..df18d46 100644 --- a/projects/ng-hcaptcha/src/lib/ng-hcaptcha-invisible-button.directive.ts +++ b/projects/ng-hcaptcha/src/lib/ng-hcaptcha-invisible-button.directive.ts @@ -59,6 +59,10 @@ export class NgHcaptchaInvisibleButtonDirective implements OnInit, OnDestroy { } ngOnDestroy() { + if (this.widgetId) { + window.hcaptcha.remove(this.widgetId); + } + if (isPlatformServer(this.platformId)) { return; } diff --git a/projects/ng-hcaptcha/src/lib/ng-hcaptcha.component.ts b/projects/ng-hcaptcha/src/lib/ng-hcaptcha.component.ts index c3d483c..d28530d 100644 --- a/projects/ng-hcaptcha/src/lib/ng-hcaptcha.component.ts +++ b/projects/ng-hcaptcha/src/lib/ng-hcaptcha.component.ts @@ -99,6 +99,10 @@ export class NgHcaptchaComponent implements OnInit, OnDestroy, ControlValueAcces } ngOnDestroy() { + if (this.widgetId) { + window.hcaptcha.remove(this.widgetId); + } + if (isPlatformServer(this.platformId)) { return; }