diff --git a/projects/angular-formio/embed/src/builder.component.ts b/projects/angular-formio/embed/src/builder.component.ts index 844264a4..786f3e2b 100644 --- a/projects/angular-formio/embed/src/builder.component.ts +++ b/projects/angular-formio/embed/src/builder.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, Input, ViewChild, Output, EventEmitter, AfterViewInit } from '@angular/core'; +import {Component, ElementRef, Input, ViewChild, Output, EventEmitter, AfterViewInit, OnDestroy} from '@angular/core'; import {Form, FormBuilder, Webform} from '@formio/js'; import WebformBuilder from '@formio/js/lib/cjs/WebformBuilder'; @@ -7,7 +7,7 @@ import WebformBuilder from '@formio/js/lib/cjs/WebformBuilder'; template: '
', standalone: false }) -export class FormioBuilder implements AfterViewInit { +export class FormioBuilder implements AfterViewInit, OnDestroy { @ViewChild('formio') element: ElementRef; @Input() form?: Form['options'] | null; @Input() options?: FormBuilder['options'] = {}; @@ -66,4 +66,8 @@ export class FormioBuilder implements AfterViewInit { this.ready.emit(this.instance); }).catch((err) => this.error.emit(err)); } + + ngOnDestroy(): void { + this.instance.destroy(true); + } }