Consider the following situation inside the same template:
<!-- createFoo -->
<form [formGroup]="fooForm1" (ngSubmit)="createFoo(fooForm1)">
<input formControlName="bar">
</form>
<!-- updateFoo -->
<form [formGroup]="fooForm2" (ngSubmit)="updateFoo(fooForm2, index)">
<input formControlName="bar">
</form>
How would I re-write this without defining the same set of forms / formControls twice in the same template?
I believe it needs to look something like this? >>>
<!-- createFoo -->
<ng-template [ngTemplateOutlet]="fooForm" [ngTemplateOutletContext]="..."></ng-template>
<!-- updateFoo -->
<ng-template [ngTemplateOutlet]="fooForm" [ngTemplateOutletContext]="..."></ng-template>
<ng-template #fooForm>
<form [formGroup]="...." (ngSubmit)="....">
<input formControlName="bar">
</form>
</ng-template>