Home > other >  Is it possible to access specific formgroup value onsubmit
Is it possible to access specific formgroup value onsubmit

Time:08-27

Inside one component,

there are 2 form groups.

Both form has a submit type input and few form controls.

like below . Form group A and B.

<form [formGroup]...>
  <input formControlName.../><button type="submit" .../>
</form>
<form [formGroup]...>
  <input formControlName.../><button type="submit" .../>
</form>

My question is, how can I access a particular form group value from these two form control, in 1 onSubmit() function ?

CodePudding user response:

Try and use this syntax:

<form (ngSubmit)="onSubmit(formGroup.value)">
</form>
  • Related