Ir al contenido

Angular

import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
import { createJsonTransport, mountForm, type MountedForm } from "mlform";
@Component({
selector: "app-prediction-form",
template: "<div #host></div>",
})
export class PredictionFormComponent implements AfterViewInit, OnDestroy {
@ViewChild("host", { static: true }) host!: ElementRef<HTMLElement>;
private mounted?: MountedForm;
ngAfterViewInit() {
this.mounted = mountForm(this.host.nativeElement, {
transport: createJsonTransport({ endpoint: "/api/predict" }),
schema,
});
}
ngOnDestroy() {
this.mounted?.unmount();
}
}