formio / angular

JSON powered forms for Angular
https://formio.github.io/angular-demo
MIT License
615 stars 462 forks source link

[Custom Components] how to execute submit action from outside formIo? #476

Closed firadisaad closed 4 years ago

firadisaad commented 4 years ago

here when i add formIo tag in my angular project : `<formio [(form)]="formPreview" (submit)="onSubmit($event)">

<button (click)="submit()">myButton `

i'm trying to click to submit button (myButton) and get form data

can someone help me ?

travist commented 4 years ago

You can always emit the submitButton event like so...

this.formio.emit('submitButton');
firadisaad commented 4 years ago

tanks for your answer, what is this.formio, i need more details please

merobal commented 4 years ago

try this:

@ViewChild(FormioComponent, { static: false })
  formio: FormioComponent;

submitButton() {
    if (this.formio) {
      this.formio.formio.emit('submitButton');
    }
  }
firadisaad commented 4 years ago

tanks, it's working 👍

Santoshah commented 1 month ago

Import formComponent from

import { FormioComponent } from '@formio/angular';